Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/pub/PubYamlUtilsTest.java

Issue 11884046: change the way we find package name from pubspec.yaml file (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/yaml/PubYamlUtils.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/pub/PubYamlUtilsTest.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/pub/PubYamlUtilsTest.java (revision 17022)
+++ editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/pub/PubYamlUtilsTest.java (working copy)
@@ -21,6 +21,8 @@
import java.util.Map;
import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class PubYamlUtilsTest extends AbstractDartCoreTest {
@@ -60,6 +62,15 @@
assertEquals("0.0.0-r.15157", map.get("unittest"));
}
+ public void test_getPubspecName() {
+ String name = PubYamlUtils.getPubspecName(pubspecYamlString);
+ assertEquals("web_components", name);
+ name = PubYamlUtils.getPubspecName(yamlStringWithErrors);
+ assertEquals("web_components", name);
+ name = PubYamlUtils.getPubspecName(yamlLockFile);
+ assertNull(name);
+ }
+
// Assert pubspec file contents can be loaded into PubYamlObject
public void test_parseYamlToObject() {
PubYamlObject object = PubYamlUtils.parsePubspecYamlToObject(pubspecYamlString);
@@ -78,6 +89,23 @@
LOG.assertEntries(IStatus.ERROR);
}
+ public void test_patternForPubspecNameLine() {
+ Matcher m = Pattern.compile(PubYamlUtils.PATTERN_PUBSPEC_NAME_LINE).matcher(pubspecYamlString);
+ assertTrue(m.find());
+ assertEquals(1, m.groupCount());
+ assertEquals("name: web_components", m.group(1));
+ m = Pattern.compile(PubYamlUtils.PATTERN_PUBSPEC_NAME_LINE).matcher(yamlStringWithErrors);
+ assertTrue(m.find());
+ assertEquals(1, m.groupCount());
+ assertEquals("name: web_components", m.group(1));
+ m = Pattern.compile(PubYamlUtils.PATTERN_PUBSPEC_NAME_LINE).matcher(yamlLockFile);
+ assertFalse(m.find());
+ m = Pattern.compile(PubYamlUtils.PATTERN_PUBSPEC_NAME_LINE).matcher(" name: sample\n");
+ assertTrue(m.find());
+ assertEquals(1, m.groupCount());
+ assertEquals("name: sample", m.group(1));
+ }
+
private void checkPubSpecsEqual(PubYamlObject object1, PubYamlObject object2) {
assertEquals(object1.name, object2.name);
assertEquals(object1.author, object2.author);
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/yaml/PubYamlUtils.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698