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 // Dart test for linked hash-maps. | 5 // Dart test for linked hash-maps. |
6 | 6 |
7 class LinkedHashMapTest { | 7 class LinkedHashMapTest { |
8 static void testMain() { | 8 static void testMain() { |
9 Map map = new LinkedHashMap(); | 9 Map map = new LinkedHashMap(); |
10 map["a"] = 1; | 10 map["a"] = 1; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 final keysInOrder = const ["a", "b", "c", "d", "e"]; | 56 final keysInOrder = const ["a", "b", "c", "d", "e"]; |
57 final valuesInOrder = const [1, 2, 3, 4, 5]; | 57 final valuesInOrder = const [1, 2, 3, 4, 5]; |
58 | 58 |
59 clear(); | 59 clear(); |
60 map.forEach(testForEachMap); | 60 map.forEach(testForEachMap); |
61 verifyKeys(keysInOrder); | 61 verifyKeys(keysInOrder); |
62 verifyValues(valuesInOrder); | 62 verifyValues(valuesInOrder); |
63 | 63 |
64 clear(); | 64 clear(); |
65 map.getKeys().forEach(testForEachKey); | 65 map.keys.forEach(testForEachKey); |
66 verifyKeys(keysInOrder); | 66 verifyKeys(keysInOrder); |
67 | 67 |
68 clear(); | 68 clear(); |
69 map.getValues().forEach(testForEachValue); | 69 map.values.forEach(testForEachValue); |
70 verifyValues(valuesInOrder); | 70 verifyValues(valuesInOrder); |
71 | 71 |
72 // Remove and then insert. | 72 // Remove and then insert. |
73 map.remove("b"); | 73 map.remove("b"); |
74 map["b"] = 6; | 74 map["b"] = 6; |
75 final keysAfterBMove = const ["a", "c", "d", "e", "b"]; | 75 final keysAfterBMove = const ["a", "c", "d", "e", "b"]; |
76 final valuesAfterBMove = const [1, 3, 4, 5, 6]; | 76 final valuesAfterBMove = const [1, 3, 4, 5, 6]; |
77 | 77 |
78 | 78 |
79 clear(); | 79 clear(); |
80 map.forEach(testForEachMap); | 80 map.forEach(testForEachMap); |
81 verifyKeys(keysAfterBMove); | 81 verifyKeys(keysAfterBMove); |
82 verifyValues(valuesAfterBMove); | 82 verifyValues(valuesAfterBMove); |
83 | 83 |
84 clear(); | 84 clear(); |
85 map.getKeys().forEach(testForEachKey); | 85 map.keys.forEach(testForEachKey); |
86 verifyKeys(keysAfterBMove); | 86 verifyKeys(keysAfterBMove); |
87 | 87 |
88 clear(); | 88 clear(); |
89 map.getValues().forEach(testForEachValue); | 89 map.values.forEach(testForEachValue); |
90 verifyValues(valuesAfterBMove); | 90 verifyValues(valuesAfterBMove); |
91 | 91 |
92 // Update. | 92 // Update. |
93 map["a"] = 0; | 93 map["a"] = 0; |
94 final valuesAfterAUpdate = const [0, 3, 4, 5, 6]; | 94 final valuesAfterAUpdate = const [0, 3, 4, 5, 6]; |
95 | 95 |
96 clear(); | 96 clear(); |
97 map.forEach(testForEachMap); | 97 map.forEach(testForEachMap); |
98 verifyKeys(keysAfterBMove); | 98 verifyKeys(keysAfterBMove); |
99 verifyValues(valuesAfterAUpdate); | 99 verifyValues(valuesAfterAUpdate); |
100 | 100 |
101 clear(); | 101 clear(); |
102 map.getKeys().forEach(testForEachKey); | 102 map.keys.forEach(testForEachKey); |
103 verifyKeys(keysAfterBMove); | 103 verifyKeys(keysAfterBMove); |
104 | 104 |
105 clear(); | 105 clear(); |
106 map.getValues().forEach(testForEachValue); | 106 map.values.forEach(testForEachValue); |
107 verifyValues(valuesAfterAUpdate); | 107 verifyValues(valuesAfterAUpdate); |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 main() { | 111 main() { |
112 LinkedHashMapTest.testMain(); | 112 LinkedHashMapTest.testMain(); |
113 } | 113 } |
OLD | NEW |