Index: pkg/analyzer/test/src/util/yaml_test.dart |
diff --git a/pkg/analyzer/test/src/util/yaml_test.dart b/pkg/analyzer/test/src/util/yaml_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5e97652d3c37d744c80d56e43be764031264e84e |
--- /dev/null |
+++ b/pkg/analyzer/test/src/util/yaml_test.dart |
@@ -0,0 +1,68 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library analyzer.test.util.yaml; |
+ |
+import 'package:analyzer/src/util/yaml.dart'; |
+import 'package:unittest/unittest.dart'; |
+ |
+import '../../utils.dart'; |
+ |
+main() { |
+ initializeTestEnvironment(); |
+ |
+ group('yaml', () { |
+ group('merge', () { |
+ test('map', () { |
+ expect( |
+ merge({ |
+ 'one': true, |
+ 'two': false, |
+ 'three': { |
+ 'nested': {'four': true} |
+ } |
+ }, { |
+ 'three': { |
+ 'nested': {'four': false, 'five': true}, |
+ 'five': true |
+ } |
Brian Wilkerson
2015/11/03 01:07:27
Add a sibling to "three" to ensure that unmatched
pquitslund
2015/11/03 18:38:09
Done.
|
+ }), |
+ equals({ |
+ 'one': true, |
+ 'two': false, |
+ 'three': { |
+ 'nested': {'four': false, 'five': true}, |
Brian Wilkerson
2015/11/03 01:07:27
Can't actually tell whether the resulting value fo
pquitslund
2015/11/03 18:38:08
Fixed.
|
+ 'five': true |
+ } |
+ })); |
+ }); |
+ |
+ test('list', () { |
+ expect(merge([1, 2, 3], [2, 3, 4, 5]), equals([1, 2, 3, 4, 5])); |
+ }); |
+ test('list w/ promotion', () { |
+ expect(merge(['one', 'two', 'three'], {'three': false, 'four': true}), |
+ equals({'one': true, 'two': true, 'three': false, 'four': true})); |
+ expect(merge({'one': false, 'two': false}, ['one', 'three']), |
+ equals({'one': true, 'two': false, 'three': true})); |
+ }); |
+ test('map w/ list promotion', () { |
+ var map1 = { |
+ 'one': ['a', 'b', 'c'] |
+ }; |
+ var map2 = { |
+ 'one': {'a': true, 'b': false} |
+ }; |
+ var map3 = { |
+ 'one': {'a': true, 'b': false, 'c': true} |
+ }; |
+ expect(merge(map1, map2), map3); |
+ }); |
Brian Wilkerson
2015/11/03 01:07:27
Consider also testing
- merging maps and lists whe
pquitslund
2015/11/03 18:38:09
Fantastic. Thanks for the nudge. It turns out my
|
+ }); |
+ }); |
+} |
+ |
+final Merger merger = new Merger(); |
+ |
+Object merge(Object o1, Object o2) => merger.merge(o1, o2); |