OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Tests that map literals are ordered. | 5 // Tests that map literals are ordered. |
6 | 6 |
7 class OrderedMapsTest { | 7 class OrderedMapsTest { |
8 static testMain() { | 8 static testMain() { |
9 testMaps(const { "a": 1, "c": 2 }, const { "c": 2, "a": 1}, true); | 9 testMaps(const { "a": 1, "c": 2 }, const { "c": 2, "a": 1}, true); |
10 testMaps({ "a": 1, "c": 2 }, { "c": 2, "a": 1 }, false); | 10 testMaps({ "a": 1, "c": 2 }, { "c": 2, "a": 1 }, false); |
11 } | 11 } |
12 | 12 |
13 static void testMaps(map1, map2, bool isConst) { | 13 static void testMaps(map1, map2, bool isConst) { |
14 Expect.equals(true, map1 !== map2); | 14 Expect.equals(true, !identical(map1, map2)); |
Lasse Reichstein Nielsen
2012/11/12 13:10:41
isFalse.
floitsch
2012/11/12 22:18:43
Done.
| |
15 | 15 |
16 var keys = map1.keys; | 16 var keys = map1.keys; |
17 Expect.equals(2, keys.length); | 17 Expect.equals(2, keys.length); |
18 Expect.equals("a", keys[0]); | 18 Expect.equals("a", keys[0]); |
19 Expect.equals("c", keys[1]); | 19 Expect.equals("c", keys[1]); |
20 | 20 |
21 keys = map2.keys; | 21 keys = map2.keys; |
22 Expect.equals(2, keys.length); | 22 Expect.equals(2, keys.length); |
23 Expect.equals("c", keys[0]); | 23 Expect.equals("c", keys[0]); |
24 Expect.equals("a", keys[1]); | 24 Expect.equals("a", keys[1]); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 | 69 |
70 values = map1.values; | 70 values = map1.values; |
71 Expect.equals(3, values.length); | 71 Expect.equals(3, values.length); |
72 Expect.equals(4, values[0]); | 72 Expect.equals(4, values[0]); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 main() { | 76 main() { |
77 OrderedMapsTest.testMain(); | 77 OrderedMapsTest.testMain(); |
78 } | 78 } |
OLD | NEW |