Index: pkg/analyzer/test/src/plugin/plugin_config_test.dart |
diff --git a/pkg/analyzer/test/src/plugin/plugin_config_test.dart b/pkg/analyzer/test/src/plugin/plugin_config_test.dart |
index 809a1ec880e5cf9639d6fcc161fa019071899b5a..a626017a743262294ad0c8afeffd846d1578eee4 100644 |
--- a/pkg/analyzer/test/src/plugin/plugin_config_test.dart |
+++ b/pkg/analyzer/test/src/plugin/plugin_config_test.dart |
@@ -7,9 +7,10 @@ library test.src.plugin.plugin_config_test; |
import 'package:analyzer/source/analysis_options_provider.dart'; |
import 'package:analyzer/src/plugin/plugin_configuration.dart'; |
import 'package:unittest/unittest.dart'; |
+import 'package:yaml/yaml.dart'; |
main() { |
- group('PluginConfig', () { |
+ group('plugin config tests', () { |
group('parsing', () { |
test('plugin map', () { |
const optionsSrc = ''' |
@@ -36,6 +37,36 @@ analyzer: |
expect(plugins[2].libraryUri, equals('myplugin/myplugin.dart')); |
expect(plugins[2].className, equals('MyPlugin')); |
}); |
+ test('plugin map (empty)', () { |
+ const optionsSrc = ''' |
+analyzer: |
+ plugins: |
+ # my_plugin1: ^0.1.0 #shorthand |
+'''; |
+ var config = parseConfig(optionsSrc); |
+ // Commented out plugins shouldn't cause a parse failure. |
+ expect(config.plugins.toList(), hasLength(0)); |
scheglov
2015/09/23 17:10:49
Do you need this toList() invocation?
AFAIK hasLen
|
+ }); |
+ group('errors', () { |
+ test('bad format', () { |
+ const optionsSrc = ''' |
+analyzer: |
+ plugins: |
+ - my_plugin1 |
+ - my_plugin2 |
+'''; |
+ try { |
+ parseConfig(optionsSrc); |
+ fail('expected PluginConfigFormatException'); |
+ } on PluginConfigFormatException catch (e) { |
+ expect( |
+ e.message, |
+ equals( |
+ 'Unrecognized plugin config format (expected `YamlMap`, got `YamlList`)')); |
+ expect(e.yamlNode, new isInstanceOf<YamlList>()); |
+ } |
+ }); |
+ }); |
}); |
}); |
} |