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

Side by Side Diff: tests/corelib/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 | « tests/corelib/json_map_test.dart ('k') | no next file » | 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 map_test; 5 library map_test;
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert' show JSON; 9 import 'dart:convert' show JSON;
10 10
11 Map newJsonMap() => JSON.decode('{}'); 11 Map newJsonMap() => JSON.decode('{}');
12 Map newJsonMapCustomReviver() => 12 Map newJsonMapCustomReviver() =>
13 JSON.decode('{}', reviver: (key, value) => value); 13 JSON.decode('{}', reviver: (key, value) => value);
14 14
15 void main() { 15 void main() {
16 test(new HashMap()); 16 test(new HashMap());
17 test(new LinkedHashMap()); 17 test(new LinkedHashMap());
18 test(new SplayTreeMap()); 18 test(new SplayTreeMap());
19 test(new SplayTreeMap(Comparable.compare)); 19 test(new SplayTreeMap(Comparable.compare));
20 test(new MapView(new HashMap())); 20 test(new MapView(new HashMap()));
21 test(new MapView(new SplayTreeMap())); 21 test(new MapView(new SplayTreeMap()));
22 test(new MapBaseMap()); 22 test(new MapBaseMap());
23 test(new MapMixinMap()); 23 test(new MapMixinMap());
24 test(newJsonMap());
25 test(newJsonMapCustomReviver());
26 testLinkedHashMap(); 24 testLinkedHashMap();
27 testMapLiteral(); 25 testMapLiteral();
28 testNullValue(); 26 testNullValue();
29 testTypes(); 27 testTypes();
30 28
31 testWeirdStringKeys(new Map()); 29 testWeirdStringKeys(new Map());
32 testWeirdStringKeys(new Map<String, String>()); 30 testWeirdStringKeys(new Map<String, String>());
33 testWeirdStringKeys(new HashMap()); 31 testWeirdStringKeys(new HashMap());
34 testWeirdStringKeys(new HashMap<String, String>()); 32 testWeirdStringKeys(new HashMap<String, String>());
35 testWeirdStringKeys(new LinkedHashMap()); 33 testWeirdStringKeys(new LinkedHashMap());
(...skipping 10 matching lines...) Expand all
46 testNumericKeys(new HashMap()); 44 testNumericKeys(new HashMap());
47 testNumericKeys(new HashMap<num, String>()); 45 testNumericKeys(new HashMap<num, String>());
48 testNumericKeys(new HashMap.identity()); 46 testNumericKeys(new HashMap.identity());
49 testNumericKeys(new HashMap<num, String>.identity()); 47 testNumericKeys(new HashMap<num, String>.identity());
50 testNumericKeys(new LinkedHashMap()); 48 testNumericKeys(new LinkedHashMap());
51 testNumericKeys(new LinkedHashMap<num, String>()); 49 testNumericKeys(new LinkedHashMap<num, String>());
52 testNumericKeys(new LinkedHashMap.identity()); 50 testNumericKeys(new LinkedHashMap.identity());
53 testNumericKeys(new LinkedHashMap<num, String>.identity()); 51 testNumericKeys(new LinkedHashMap<num, String>.identity());
54 testNumericKeys(new MapBaseMap<num, String>()); 52 testNumericKeys(new MapBaseMap<num, String>());
55 testNumericKeys(new MapMixinMap<num, String>()); 53 testNumericKeys(new MapMixinMap<num, String>());
56 testNumericKeys(newJsonMap());
57 testNumericKeys(newJsonMapCustomReviver());
58 54
59 testNaNKeys(new Map()); 55 testNaNKeys(new Map());
60 testNaNKeys(new Map<num, String>()); 56 testNaNKeys(new Map<num, String>());
61 testNaNKeys(new HashMap()); 57 testNaNKeys(new HashMap());
62 testNaNKeys(new HashMap<num, String>()); 58 testNaNKeys(new HashMap<num, String>());
63 testNaNKeys(new LinkedHashMap()); 59 testNaNKeys(new LinkedHashMap());
64 testNaNKeys(new LinkedHashMap<num, String>()); 60 testNaNKeys(new LinkedHashMap<num, String>());
65 testNaNKeys(new MapBaseMap<num, String>()); 61 testNaNKeys(new MapBaseMap<num, String>());
66 testNaNKeys(new MapMixinMap<num, String>()); 62 testNaNKeys(new MapMixinMap<num, String>());
67 testNaNKeys(newJsonMap());
68 testNaNKeys(newJsonMapCustomReviver());
69 // Identity maps fail the NaN-keys tests because the test assumes that 63 // Identity maps fail the NaN-keys tests because the test assumes that
70 // NaN is not equal to NaN. 64 // NaN is not equal to NaN.
71 65
72 testIdentityMap(new Map.identity()); 66 testIdentityMap(new Map.identity());
73 testIdentityMap(new HashMap.identity()); 67 testIdentityMap(new HashMap.identity());
74 testIdentityMap(new LinkedHashMap.identity()); 68 testIdentityMap(new LinkedHashMap.identity());
75 testIdentityMap(new HashMap(equals: identical, hashCode: identityHashCode)); 69 testIdentityMap(new HashMap(equals: identical, hashCode: identityHashCode));
76 testIdentityMap( 70 testIdentityMap(
77 new LinkedHashMap(equals: identical, hashCode: identityHashCode)); 71 new LinkedHashMap(equals: identical, hashCode: identityHashCode));
78 testIdentityMap(new HashMap( 72 testIdentityMap(new HashMap(
(...skipping 10 matching lines...) Expand all
89 hashCode: myHashCode, 83 hashCode: myHashCode,
90 isValidKey: (v) => v is Customer)); 84 isValidKey: (v) => v is Customer));
91 testCustomMap( 85 testCustomMap(
92 new HashMap<Customer, dynamic>(equals: myEquals, hashCode: myHashCode)); 86 new HashMap<Customer, dynamic>(equals: myEquals, hashCode: myHashCode));
93 87
94 testCustomMap(new LinkedHashMap<Customer, dynamic>( 88 testCustomMap(new LinkedHashMap<Customer, dynamic>(
95 equals: myEquals, hashCode: myHashCode)); 89 equals: myEquals, hashCode: myHashCode));
96 90
97 testIterationOrder(new LinkedHashMap()); 91 testIterationOrder(new LinkedHashMap());
98 testIterationOrder(new LinkedHashMap.identity()); 92 testIterationOrder(new LinkedHashMap.identity());
99 testIterationOrder(newJsonMap());
100 testIterationOrder(newJsonMapCustomReviver());
101 93
102 testOtherKeys(new SplayTreeMap<int, int>()); 94 testOtherKeys(new SplayTreeMap<int, int>());
103 testOtherKeys( 95 testOtherKeys(
104 new SplayTreeMap<int, int>((int a, int b) => a - b, (v) => v is int)); 96 new SplayTreeMap<int, int>((int a, int b) => a - b, (v) => v is int));
105 testOtherKeys(new SplayTreeMap((int a, int b) => a - b, (v) => v is int)); 97 testOtherKeys(new SplayTreeMap((int a, int b) => a - b, (v) => v is int));
106 testOtherKeys(new HashMap<int, int>()); 98 testOtherKeys(new HashMap<int, int>());
107 testOtherKeys(new HashMap<int, int>.identity()); 99 testOtherKeys(new HashMap<int, int>.identity());
108 testOtherKeys(new HashMap<int, int>( 100 testOtherKeys(new HashMap<int, int>(
109 hashCode: (v) => v.hashCode, isValidKey: (v) => v is int)); 101 hashCode: (v) => v.hashCode, isValidKey: (v) => v is int));
110 testOtherKeys(new HashMap( 102 testOtherKeys(new HashMap(
111 equals: (int x, int y) => x == y, 103 equals: (int x, int y) => x == y,
112 hashCode: (int v) => v.hashCode, 104 hashCode: (int v) => v.hashCode,
113 isValidKey: (v) => v is int)); 105 isValidKey: (v) => v is int));
114 testOtherKeys(new LinkedHashMap<int, int>()); 106 testOtherKeys(new LinkedHashMap<int, int>());
115 testOtherKeys(new LinkedHashMap<int, int>.identity()); 107 testOtherKeys(new LinkedHashMap<int, int>.identity());
116 testOtherKeys(new LinkedHashMap<int, int>( 108 testOtherKeys(new LinkedHashMap<int, int>(
117 hashCode: (v) => v.hashCode, isValidKey: (v) => v is int)); 109 hashCode: (v) => v.hashCode, isValidKey: (v) => v is int));
118 testOtherKeys(new LinkedHashMap( 110 testOtherKeys(new LinkedHashMap(
119 equals: (int x, int y) => x == y, 111 equals: (int x, int y) => x == y,
120 hashCode: (int v) => v.hashCode, 112 hashCode: (int v) => v.hashCode,
121 isValidKey: (v) => v is int)); 113 isValidKey: (v) => v is int));
122 testOtherKeys(new MapBaseMap<int, int>()); 114 testOtherKeys(new MapBaseMap<int, int>());
123 testOtherKeys(new MapMixinMap<int, int>()); 115 testOtherKeys(new MapMixinMap<int, int>());
124 testOtherKeys(newJsonMap());
125 testOtherKeys(newJsonMapCustomReviver());
126 116
127 testUnmodifiableMap(const {1: 37}); 117 testUnmodifiableMap(const {1: 37});
128 testUnmodifiableMap(new UnmodifiableMapView({1: 37})); 118 testUnmodifiableMap(new UnmodifiableMapView({1: 37}));
129 testUnmodifiableMap(new UnmodifiableMapBaseMap([1, 37])); 119 testUnmodifiableMap(new UnmodifiableMapBaseMap([1, 37]));
130 120
131 testFrom(); 121 testFrom();
132 } 122 }
133 123
134 void test(Map map) { 124 void test(Map map) {
135 testDeletedElement(map); 125 testDeletedElement(map);
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 Map<Interface, Interface> interfaceMap = <Interface, Interface>{sub: sub}; 965 Map<Interface, Interface> interfaceMap = <Interface, Interface>{sub: sub};
976 expectMap(superMap, new Map<Super, Super>.from(interfaceMap)); 966 expectMap(superMap, new Map<Super, Super>.from(interfaceMap));
977 expectMap(superMap, new Map<Interface, Interface>.from(superMap)); 967 expectMap(superMap, new Map<Interface, Interface>.from(superMap));
978 expectMap(superMap, new HashMap<Super, Super>.from(interfaceMap)); 968 expectMap(superMap, new HashMap<Super, Super>.from(interfaceMap));
979 expectMap(superMap, new HashMap<Interface, Interface>.from(superMap)); 969 expectMap(superMap, new HashMap<Interface, Interface>.from(superMap));
980 expectMap(superMap, new LinkedHashMap<Super, Super>.from(interfaceMap)); 970 expectMap(superMap, new LinkedHashMap<Super, Super>.from(interfaceMap));
981 expectMap(superMap, new LinkedHashMap<Interface, Interface>.from(superMap)); 971 expectMap(superMap, new LinkedHashMap<Interface, Interface>.from(superMap));
982 expectMap(superMap, new SplayTreeMap<Super, Super>.from(interfaceMap)); 972 expectMap(superMap, new SplayTreeMap<Super, Super>.from(interfaceMap));
983 expectMap(superMap, new SplayTreeMap<Interface, Interface>.from(superMap)); 973 expectMap(superMap, new SplayTreeMap<Interface, Interface>.from(superMap));
984 } 974 }
OLDNEW
« no previous file with comments | « tests/corelib/json_map_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698