OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 const m1 = const { 'a': 400 + 99 }; | 5 const m1 = const { 'a': 400 + 99 }; |
6 const m2 = const { 'a': 499, 'b': 42 }; | 6 const m2 = const { 'a': 499, 'b': 42 }; |
7 const m3 = const { 'm1': m1, 'm2': m2 }; | 7 const m3 = const { 'm1': m1, 'm2': m2 }; |
8 const m4 = const { 'z': 9, 'a': 8, 'm': 7 }; | 8 const m4 = const { 'z': 9, 'a': 8, 'm': 7 }; |
9 const m5 = const { '': 499 }; | 9 const m5 = const { '': 499 }; |
10 const m6 = const { 'a': 499 }; | 10 const m6 = const { 'a': 499 }; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 Expect.throws(() => m2.remove('b'), isUnsupportedError); | 66 Expect.throws(() => m2.remove('b'), isUnsupportedError); |
67 Expect.throws(() => m2.remove('c'), isUnsupportedError); | 67 Expect.throws(() => m2.remove('c'), isUnsupportedError); |
68 Expect.throws(() => m2.clear(), isUnsupportedError); | 68 Expect.throws(() => m2.clear(), isUnsupportedError); |
69 Expect.throws(() => m2['a'] = 499, isUnsupportedError); | 69 Expect.throws(() => m2['a'] = 499, isUnsupportedError); |
70 Expect.throws(() => m2['b'] = 42, isUnsupportedError); | 70 Expect.throws(() => m2['b'] = 42, isUnsupportedError); |
71 Expect.throws(() => m2['c'] = 499, isUnsupportedError); | 71 Expect.throws(() => m2['c'] = 499, isUnsupportedError); |
72 Expect.throws(() => m2.putIfAbsent('a', () => 499), isUnsupportedError); | 72 Expect.throws(() => m2.putIfAbsent('a', () => 499), isUnsupportedError); |
73 Expect.throws(() => m2.putIfAbsent('z', () => 499), isUnsupportedError); | 73 Expect.throws(() => m2.putIfAbsent('z', () => 499), isUnsupportedError); |
74 Expect.throws(() => m2['a'] = 499, isUnsupportedError); | 74 Expect.throws(() => m2['a'] = 499, isUnsupportedError); |
75 | 75 |
76 Expect.isTrue(m3['m1'] === m1); | 76 Expect.isTrue(identical(m3['m1'], m1)); |
Lasse Reichstein Nielsen
2012/11/12 13:10:41
Expect.identical
floitsch
2012/11/12 22:18:43
Done.
| |
77 Expect.isTrue(m3['m2'] === m2); | 77 Expect.isTrue(identical(m3['m2'], m2)); |
78 | 78 |
79 Expect.listEquals(['z', 'a', 'm'], m4.keys); | 79 Expect.listEquals(['z', 'a', 'm'], m4.keys); |
80 Expect.listEquals([9, 8, 7], m4.values); | 80 Expect.listEquals([9, 8, 7], m4.values); |
81 seenKeys = []; | 81 seenKeys = []; |
82 seenValues = []; | 82 seenValues = []; |
83 m4.forEach((key, value) { | 83 m4.forEach((key, value) { |
84 seenKeys.add(key); | 84 seenKeys.add(key); |
85 seenValues.add(value); | 85 seenValues.add(value); |
86 }); | 86 }); |
87 Expect.listEquals(['z', 'a', 'm'], seenKeys); | 87 Expect.listEquals(['z', 'a', 'm'], seenKeys); |
88 Expect.listEquals([9, 8, 7], seenValues); | 88 Expect.listEquals([9, 8, 7], seenValues); |
89 | 89 |
90 Expect.equals(499, m5['']); | 90 Expect.equals(499, m5['']); |
91 Expect.isTrue(m5.containsKey('')); | 91 Expect.isTrue(m5.containsKey('')); |
92 Expect.equals(1, m5.length); | 92 Expect.equals(1, m5.length); |
93 | 93 |
94 Expect.isTrue(m1 === m6); | 94 Expect.isTrue(identical(m1, m6)); |
95 | 95 |
96 Expect.isTrue(m7.isEmpty); | 96 Expect.isTrue(m7.isEmpty); |
97 Expect.equals(0, m7.length); | 97 Expect.equals(0, m7.length); |
98 Expect.equals(null, m7['b']); | 98 Expect.equals(null, m7['b']); |
99 Expect.listEquals([], m7.keys); | 99 Expect.listEquals([], m7.keys); |
100 Expect.listEquals([], m7.values); | 100 Expect.listEquals([], m7.values); |
101 Expect.isFalse(m7.containsKey('a')); | 101 Expect.isFalse(m7.containsKey('a')); |
102 Expect.isFalse(m7.containsKey('toString')); | 102 Expect.isFalse(m7.containsKey('toString')); |
103 Expect.isFalse(m7.containsValue(499)); | 103 Expect.isFalse(m7.containsValue(499)); |
104 Expect.isFalse(m7.containsValue(null)); | 104 Expect.isFalse(m7.containsValue(null)); |
105 seenKeys = []; | 105 seenKeys = []; |
106 seenValues = []; | 106 seenValues = []; |
107 m7.forEach((key, value) { | 107 m7.forEach((key, value) { |
108 seenKeys.add(key); | 108 seenKeys.add(key); |
109 seenValues.add(value); | 109 seenValues.add(value); |
110 }); | 110 }); |
111 Expect.listEquals([], seenKeys); | 111 Expect.listEquals([], seenKeys); |
112 Expect.listEquals([], seenValues); | 112 Expect.listEquals([], seenValues); |
113 Expect.throws(() => m7.remove('a'), isUnsupportedError); | 113 Expect.throws(() => m7.remove('a'), isUnsupportedError); |
114 Expect.throws(() => m7.remove('b'), isUnsupportedError); | 114 Expect.throws(() => m7.remove('b'), isUnsupportedError); |
115 Expect.throws(() => m7.clear(), isUnsupportedError); | 115 Expect.throws(() => m7.clear(), isUnsupportedError); |
116 Expect.throws(() => m7['b'] = 42, isUnsupportedError); | 116 Expect.throws(() => m7['b'] = 42, isUnsupportedError); |
117 Expect.throws(() => m7['a'] = 499, isUnsupportedError); | 117 Expect.throws(() => m7['a'] = 499, isUnsupportedError); |
118 Expect.throws(() => m7.putIfAbsent('a', () => 499), | 118 Expect.throws(() => m7.putIfAbsent('a', () => 499), |
119 isUnsupportedError); | 119 isUnsupportedError); |
120 Expect.throws(() => m7.putIfAbsent('z', () => 499), | 120 Expect.throws(() => m7.putIfAbsent('z', () => 499), |
121 isUnsupportedError); | 121 isUnsupportedError); |
122 } | 122 } |
OLD | NEW |