| 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 library json_map_test; | 5 library json_map_test; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:convert' show JSON; | 8 import 'dart:convert' show JSON; |
| 9 import 'dart:collection' show LinkedHashMap, HashMap; | 9 import 'dart:collection' show LinkedHashMap, HashMap; |
| 10 | 10 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 void testToString() { | 156 void testToString() { |
| 157 Expect.equals("{}", jsonify({}).toString()); | 157 Expect.equals("{}", jsonify({}).toString()); |
| 158 Expect.equals("{a: 0}", jsonify({'a': 0}).toString()); | 158 Expect.equals("{a: 0}", jsonify({'a': 0}).toString()); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void testConcurrentModifications() { | 161 void testConcurrentModifications() { |
| 162 void testIterate(Map map, Iterable iterable, Function f) { | 162 void testIterate(Map map, Iterable iterable, Function f) { |
| 163 Iterator iterator = iterable.iterator; | 163 Iterator iterator = iterable.iterator; |
| 164 f(map); | 164 f(map); |
| 165 iterator.moveNext(); | 165 while (iterator.moveNext()); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void testKeys(Map map, Function f) => testIterate(map, map.keys, f); | 168 void testKeys(Map map, Function f) => testIterate(map, map.keys, f); |
| 169 void testValues(Map map, Function f) => testIterate(map, map.values, f); | 169 void testValues(Map map, Function f) => testIterate(map, map.values, f); |
| 170 | 170 |
| 171 void testForEach(Map map, Function f) { | 171 void testForEach(Map map, Function f) { |
| 172 map.forEach((key, value) { | 172 map.forEach((key, value) { |
| 173 f(map); | 173 f(map); |
| 174 }); | 174 }); |
| 175 } | 175 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 337 } |
| 338 | 338 |
| 339 void testMutation() { | 339 void testMutation() { |
| 340 Map map = jsonify({'a': 0}); | 340 Map map = jsonify({'a': 0}); |
| 341 Expect.listEquals(['a', 0], listEach(map)); | 341 Expect.listEquals(['a', 0], listEach(map)); |
| 342 map['a'] = 1; | 342 map['a'] = 1; |
| 343 Expect.listEquals(['a', 1], listEach(map)); | 343 Expect.listEquals(['a', 1], listEach(map)); |
| 344 map['a']++; | 344 map['a']++; |
| 345 Expect.listEquals(['a', 2], listEach(map)); | 345 Expect.listEquals(['a', 2], listEach(map)); |
| 346 } | 346 } |
| OLD | NEW |