| 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);
|
|
|