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

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

Issue 11267018: Make getKeys, getValues getters (keys, values). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « tests/language/ct_const_test.dart ('k') | tests/language/method_override_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 // A subtest of the larger MapTest. Will eliminate once the full 4 // A subtest of the larger MapTest. Will eliminate once the full
5 // test is running. 5 // test is running.
6 6
7 class MapTest { 7 class MapTest {
8 8
9 static void testDeletedElement(Map map) { 9 static void testDeletedElement(Map map) {
10 map.clear(); 10 map.clear();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 map.forEach(testForEachMap); 147 map.forEach(testForEachMap);
148 Expect.equals(true, other_map.containsKey(key1)); 148 Expect.equals(true, other_map.containsKey(key1));
149 Expect.equals(true, other_map.containsKey(key2)); 149 Expect.equals(true, other_map.containsKey(key2));
150 Expect.equals(true, other_map.containsValue(value1)); 150 Expect.equals(true, other_map.containsValue(value1));
151 Expect.equals(true, other_map.containsValue(value2)); 151 Expect.equals(true, other_map.containsValue(value2));
152 Expect.equals(2, other_map.length); 152 Expect.equals(2, other_map.length);
153 153
154 other_map.clear(); 154 other_map.clear();
155 Expect.equals(0, other_map.length); 155 Expect.equals(0, other_map.length);
156 156
157 // Test Collection.getKeys. 157 // Test Collection.keys.
158 void testForEachCollection(value) { 158 void testForEachCollection(value) {
159 other_map[value] = value; 159 other_map[value] = value;
160 } 160 }
161 Collection keys = map.getKeys(); 161 Collection keys = map.keys;
162 keys.forEach(testForEachCollection); 162 keys.forEach(testForEachCollection);
163 Expect.equals(true, other_map.containsKey(key1)); 163 Expect.equals(true, other_map.containsKey(key1));
164 Expect.equals(true, other_map.containsKey(key2)); 164 Expect.equals(true, other_map.containsKey(key2));
165 Expect.equals(true, other_map.containsValue(key1)); 165 Expect.equals(true, other_map.containsValue(key1));
166 Expect.equals(true, other_map.containsValue(key2)); 166 Expect.equals(true, other_map.containsValue(key2));
167 Expect.equals(true, !other_map.containsKey(value1)); 167 Expect.equals(true, !other_map.containsKey(value1));
168 Expect.equals(true, !other_map.containsKey(value2)); 168 Expect.equals(true, !other_map.containsKey(value2));
169 Expect.equals(true, !other_map.containsValue(value1)); 169 Expect.equals(true, !other_map.containsValue(value1));
170 Expect.equals(true, !other_map.containsValue(value2)); 170 Expect.equals(true, !other_map.containsValue(value2));
171 Expect.equals(2, other_map.length); 171 Expect.equals(2, other_map.length);
172 other_map.clear(); 172 other_map.clear();
173 Expect.equals(0, other_map.length); 173 Expect.equals(0, other_map.length);
174 174
175 // Test Collection.getValues. 175 // Test Collection.values.
176 Collection values = map.getValues(); 176 Collection values = map.values;
177 values.forEach(testForEachCollection); 177 values.forEach(testForEachCollection);
178 Expect.equals(true, !other_map.containsKey(key1)); 178 Expect.equals(true, !other_map.containsKey(key1));
179 Expect.equals(true, !other_map.containsKey(key2)); 179 Expect.equals(true, !other_map.containsKey(key2));
180 Expect.equals(true, !other_map.containsValue(key1)); 180 Expect.equals(true, !other_map.containsValue(key1));
181 Expect.equals(true, !other_map.containsValue(key2)); 181 Expect.equals(true, !other_map.containsValue(key2));
182 Expect.equals(true, other_map.containsKey(value1)); 182 Expect.equals(true, other_map.containsKey(value1));
183 Expect.equals(true, other_map.containsKey(value2)); 183 Expect.equals(true, other_map.containsKey(value2));
184 Expect.equals(true, other_map.containsValue(value1)); 184 Expect.equals(true, other_map.containsValue(value1));
185 Expect.equals(true, other_map.containsValue(value2)); 185 Expect.equals(true, other_map.containsValue(value2));
186 Expect.equals(2, other_map.length); 186 Expect.equals(2, other_map.length);
187 other_map.clear(); 187 other_map.clear();
188 Expect.equals(0, other_map.length); 188 Expect.equals(0, other_map.length);
189 189
190 // Test Map.putIfAbsent. 190 // Test Map.putIfAbsent.
191 map.clear(); 191 map.clear();
192 Expect.equals(false, map.containsKey(key1)); 192 Expect.equals(false, map.containsKey(key1));
193 map.putIfAbsent(key1, () => 10); 193 map.putIfAbsent(key1, () => 10);
194 Expect.equals(true, map.containsKey(key1)); 194 Expect.equals(true, map.containsKey(key1));
195 Expect.equals(10, map[key1]); 195 Expect.equals(10, map[key1]);
196 Expect.equals(10, 196 Expect.equals(10,
197 map.putIfAbsent(key1, () => 11)); 197 map.putIfAbsent(key1, () => 11));
198 } 198 }
199 199
200 static testKeys(Map map) { 200 static testKeys(Map map) {
201 map[1] = 101; 201 map[1] = 101;
202 map[2] = 102; 202 map[2] = 102;
203 Collection k = map.getKeys(); 203 Collection k = map.keys;
204 Expect.equals(2, k.length); 204 Expect.equals(2, k.length);
205 Collection v = map.getValues(); 205 Collection v = map.values;
206 Expect.equals(2, v.length); 206 Expect.equals(2, v.length);
207 Expect.equals(true, map.containsValue(101)); 207 Expect.equals(true, map.containsValue(101));
208 Expect.equals(true, map.containsValue(102)); 208 Expect.equals(true, map.containsValue(102));
209 Expect.equals(false, map.containsValue(103)); 209 Expect.equals(false, map.containsValue(103));
210 } 210 }
211 211
212 static testMain() { 212 static testMain() {
213 test(new Map()); 213 test(new Map());
214 testKeys(new Map()); 214 testKeys(new Map());
215 } 215 }
216 } 216 }
217 217
218 218
219 main() { 219 main() {
220 MapTest.testMain(); 220 MapTest.testMain();
221 } 221 }
OLDNEW
« no previous file with comments | « tests/language/ct_const_test.dart ('k') | tests/language/method_override_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698