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 /** | 5 /** |
6 * A test of simple runtime behavior on numbers, strings and lists with | 6 * A test of simple runtime behavior on numbers, strings and lists with |
7 * a focus on both correct behavior and runtime errors. | 7 * a focus on both correct behavior and runtime errors. |
8 * | 8 * |
9 * This file is written to use minimal type declarations to match a | 9 * This file is written to use minimal type declarations to match a |
10 * typical dynamic language coding style. | 10 * typical dynamic language coding style. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 d['b'] = 2; | 214 d['b'] = 2; |
215 assertEquals(d.containsValue(2), true); | 215 assertEquals(d.containsValue(2), true); |
216 assertEquals(d.containsValue(3), false); | 216 assertEquals(d.containsValue(3), false); |
217 assertEquals(d.containsKey('a'), true); | 217 assertEquals(d.containsKey('a'), true); |
218 assertEquals(d.containsKey('c'), false); | 218 assertEquals(d.containsKey('c'), false); |
219 assertEquals(d.keys.length, 2); | 219 assertEquals(d.keys.length, 2); |
220 assertEquals(d.values.length, 2); | 220 assertEquals(d.values.length, 2); |
221 | 221 |
222 assertEquals(d.remove('c'), null); | 222 assertEquals(d.remove('c'), null); |
223 assertEquals(d.remove('b'), 2); | 223 assertEquals(d.remove('b'), 2); |
224 assertListEquals(d.keys, ['a']); | 224 assertEquals(d.keys.single, 'a'); |
225 assertListEquals(d.values, [1]); | 225 assertEquals(d.values.single, 1); |
226 | 226 |
227 d['c'] = 3; | 227 d['c'] = 3; |
228 d['f'] = 4; | 228 d['f'] = 4; |
229 assertEquals(d.keys.length, 3); | 229 assertEquals(d.keys.length, 3); |
230 assertEquals(d.values.length, 3); | 230 assertEquals(d.values.length, 3); |
231 assertListContains(d.keys, ['a', 'c', 'f']); | 231 assertListContains(d.keys.toList(), ['a', 'c', 'f']); |
232 assertListContains(d.values, [1, 3, 4]); | 232 assertListContains(d.values.toList(), [1, 3, 4]); |
233 | 233 |
234 var count = 0; | 234 var count = 0; |
235 d.forEach((key, value) { | 235 d.forEach((key, value) { |
236 count++; | 236 count++; |
237 assertEquals(value, d[key]); | 237 assertEquals(value, d[key]); |
238 }); | 238 }); |
239 assertEquals(count, 3); | 239 assertEquals(count, 3); |
240 | 240 |
241 d = { 'a': 1, 'b': 2 }; | 241 d = { 'a': 1, 'b': 2 }; |
242 assertEquals(d.containsValue(2), true); | 242 assertEquals(d.containsValue(2), true); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 '${true}'.toString(); | 274 '${true}'.toString(); |
275 '${false}'.toString(); | 275 '${false}'.toString(); |
276 ''.toString(); | 276 ''.toString(); |
277 ''.endsWith(''); | 277 ''.endsWith(''); |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 main() { | 281 main() { |
282 CoreRuntimeTypesTest.testMain(); | 282 CoreRuntimeTypesTest.testMain(); |
283 } | 283 } |
OLD | NEW |