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

Side by Side Diff: pkg/analyzer/test/src/util/yaml_test.dart

Issue 1425393002: Map merging. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/test/src/util/test_all.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library analyzer.test.util.yaml;
6
7 import 'package:analyzer/src/util/yaml.dart';
8 import 'package:unittest/unittest.dart';
9
10 import '../../utils.dart';
11
12 main() {
13 initializeTestEnvironment();
14
15 group('yaml', () {
16 group('merge', () {
17 test('map', () {
18 expect(
19 merge({
20 'one': true,
21 'two': false,
22 'three': {
23 'nested': {'four': true}
24 }
25 }, {
26 'three': {
27 'nested': {'four': false, 'five': true},
28 'five': true
29 }
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.
30 }),
31 equals({
32 'one': true,
33 'two': false,
34 'three': {
35 '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.
36 'five': true
37 }
38 }));
39 });
40
41 test('list', () {
42 expect(merge([1, 2, 3], [2, 3, 4, 5]), equals([1, 2, 3, 4, 5]));
43 });
44 test('list w/ promotion', () {
45 expect(merge(['one', 'two', 'three'], {'three': false, 'four': true}),
46 equals({'one': true, 'two': true, 'three': false, 'four': true}));
47 expect(merge({'one': false, 'two': false}, ['one', 'three']),
48 equals({'one': true, 'two': false, 'three': true}));
49 });
50 test('map w/ list promotion', () {
51 var map1 = {
52 'one': ['a', 'b', 'c']
53 };
54 var map2 = {
55 'one': {'a': true, 'b': false}
56 };
57 var map3 = {
58 'one': {'a': true, 'b': false, 'c': true}
59 };
60 expect(merge(map1, map2), map3);
61 });
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
62 });
63 });
64 }
65
66 final Merger merger = new Merger();
67
68 Object merge(Object o1, Object o2) => merger.merge(o1, o2);
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/util/test_all.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698