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

Side by Side Diff: tests/language/ordered_maps_test.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « tests/language/optimized_lists_test.dart ('k') | tests/language/string_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.isFalse(identical(map1, map2)); 14 Expect.isFalse(identical(map1, map2));
15 15
16 var keys = map1.keys; 16 var keys = map1.keys.toList();
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.toList();
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]);
25 25
26 var values = map1.values; 26 var values = map1.values.toList();
27 Expect.equals(2, values.length); 27 Expect.equals(2, values.length);
28 Expect.equals(1, values[0]); 28 Expect.equals(1, values[0]);
29 Expect.equals(2, values[1]); 29 Expect.equals(2, values[1]);
30 30
31 values = map2.values; 31 values = map2.values.toList();
32 Expect.equals(2, values.length); 32 Expect.equals(2, values.length);
33 Expect.equals(2, values[0]); 33 Expect.equals(2, values[0]);
34 Expect.equals(1, values[1]); 34 Expect.equals(1, values[1]);
35 35
36 if (isConst) return; 36 if (isConst) return;
37 37
38 map1["b"] = 3; 38 map1["b"] = 3;
39 map2["b"] = 3; 39 map2["b"] = 3;
40 40
41 keys = map1.keys; 41 keys = map1.keys.toList();
42 Expect.equals(3, keys.length); 42 Expect.equals(3, keys.length);
43 Expect.equals("a", keys[0]); 43 Expect.equals("a", keys[0]);
44 Expect.equals("c", keys[1]); 44 Expect.equals("c", keys[1]);
45 Expect.equals("b", keys[2]); 45 Expect.equals("b", keys[2]);
46 46
47 keys = map2.keys; 47 keys = map2.keys.toList();
48 Expect.equals(3, keys.length); 48 Expect.equals(3, keys.length);
49 Expect.equals("c", keys[0]); 49 Expect.equals("c", keys[0]);
50 Expect.equals("a", keys[1]); 50 Expect.equals("a", keys[1]);
51 Expect.equals("b", keys[2]); 51 Expect.equals("b", keys[2]);
52 52
53 values = map1.values; 53 values = map1.values.toList();
54 Expect.equals(3, values.length); 54 Expect.equals(3, values.length);
55 Expect.equals(1, values[0]); 55 Expect.equals(1, values[0]);
56 Expect.equals(2, values[1]); 56 Expect.equals(2, values[1]);
57 Expect.equals(3, values[2]); 57 Expect.equals(3, values[2]);
58 58
59 values = map2.values; 59 values = map2.values.toList();
60 Expect.equals(3, values.length); 60 Expect.equals(3, values.length);
61 Expect.equals(2, values[0]); 61 Expect.equals(2, values[0]);
62 Expect.equals(1, values[1]); 62 Expect.equals(1, values[1]);
63 Expect.equals(3, values[2]); 63 Expect.equals(3, values[2]);
64 64
65 map1["a"] = 4; 65 map1["a"] = 4;
66 keys = map1.keys; 66 keys = map1.keys.toList();
67 Expect.equals(3, keys.length); 67 Expect.equals(3, keys.length);
68 Expect.equals("a", keys[0]); 68 Expect.equals("a", keys[0]);
69 69
70 values = map1.values; 70 values = map1.values.toList();
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 }
OLDNEW
« no previous file with comments | « tests/language/optimized_lists_test.dart ('k') | tests/language/string_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698