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

Side by Side Diff: tests/corelib/json_map_test.dart

Issue 1980663002: Make json-maps implement Map<String, dynamic>. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Changelog and test updates Created 3 years, 7 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
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/convert_patch.dart ('k') | tests/corelib/map_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 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 map = jsonify({}); 46 map = jsonify({});
47 map.addAll({'a': 'b'}); 47 map.addAll({'a': 'b'});
48 testAtoB(map); 48 testAtoB(map);
49 49
50 testOrder(['a', 'b', 'c', 'd', 'e', 'f']); 50 testOrder(['a', 'b', 'c', 'd', 'e', 'f']);
51 51
52 testProto(); 52 testProto();
53 testToString(); 53 testToString();
54 testConcurrentModifications(); 54 testConcurrentModifications();
55 testType(); 55 testType();
56 testNonStringKeys();
57 testClear(); 56 testClear();
58 57
59 testListEntry(); 58 testListEntry();
60 testMutation(); 59 testMutation();
61 } 60 }
62 61
63 void testEmpty(Map map) { 62 void testEmpty(Map map) {
64 for (int i = 0; i < 2; i++) { 63 for (int i = 0; i < 2; i++) {
65 Expect.equals(0, map.length); 64 Expect.equals(0, map.length);
66 Expect.isTrue(map.isEmpty); 65 Expect.isTrue(map.isEmpty);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 Expect.isTrue( 292 Expect.isTrue(
294 throwsCME(() => testKeys(jsonify(map), (map) => map.addAll({'b': 0})))); 293 throwsCME(() => testKeys(jsonify(map), (map) => map.addAll({'b': 0}))));
295 Expect.isTrue( 294 Expect.isTrue(
296 throwsCME(() => testValues(jsonify(map), (map) => map.addAll({'b': 0})))); 295 throwsCME(() => testValues(jsonify(map), (map) => map.addAll({'b': 0}))));
297 Expect.isTrue(throwsCME( 296 Expect.isTrue(throwsCME(
298 () => testForEach(jsonify(map), (map) => map.addAll({'b': 0})))); 297 () => testForEach(jsonify(map), (map) => map.addAll({'b': 0}))));
299 } 298 }
300 299
301 void testType() { 300 void testType() {
302 Expect.isTrue(jsonify({}) is Map); 301 Expect.isTrue(jsonify({}) is Map);
303 Expect.isTrue(jsonify({}) is HashMap);
304 Expect.isTrue(jsonify({}) is LinkedHashMap);
305
306 Expect.isTrue(jsonify({}) is Map<String, dynamic>); 302 Expect.isTrue(jsonify({}) is Map<String, dynamic>);
307 Expect.isTrue(jsonify({}) is HashMap<String, dynamic>); 303 Expect.isFalse(jsonify({}) is Map<int, dynamic>);
308 Expect.isTrue(jsonify({}) is LinkedHashMap<String, dynamic>);
309
310 Expect.isTrue(jsonify({}) is Map<int, dynamic>);
311 Expect.isTrue(jsonify({}) is HashMap<int, dynamic>);
312 Expect.isTrue(jsonify({}) is LinkedHashMap<int, dynamic>);
313 }
314
315 void testNonStringKeys() {
316 Map map = jsonify({});
317 map[1] = 2;
318 Expect.equals(1, map.length);
319 Expect.equals(2, map[1]);
320 } 304 }
321 305
322 void testClear() { 306 void testClear() {
323 Map map = jsonify({'a': 0}); 307 Map map = jsonify({'a': 0});
324 map.clear(); 308 map.clear();
325 Expect.equals(0, map.length); 309 Expect.equals(0, map.length);
326 } 310 }
327 311
328 void testListEntry() { 312 void testListEntry() {
329 Map map = jsonify({ 313 Map map = jsonify({
(...skipping 11 matching lines...) Expand all
341 } 325 }
342 326
343 void testMutation() { 327 void testMutation() {
344 Map map = jsonify({'a': 0}); 328 Map map = jsonify({'a': 0});
345 Expect.listEquals(['a', 0], listEach(map)); 329 Expect.listEquals(['a', 0], listEach(map));
346 map['a'] = 1; 330 map['a'] = 1;
347 Expect.listEquals(['a', 1], listEach(map)); 331 Expect.listEquals(['a', 1], listEach(map));
348 map['a']++; 332 map['a']++;
349 Expect.listEquals(['a', 2], listEach(map)); 333 Expect.listEquals(['a', 2], listEach(map));
350 } 334 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/convert_patch.dart ('k') | tests/corelib/map_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698