Index: tests/corelib_2/map_test.dart |
diff --git a/tests/corelib/map_test.dart b/tests/corelib_2/map_test.dart |
similarity index 96% |
rename from tests/corelib/map_test.dart |
rename to tests/corelib_2/map_test.dart |
index 9881be945b01caeba2d0f85faa0f3f98b5f1aa64..afc74cdbd6dff0e60e4b5f9b6dbf669602859ee9 100644 |
--- a/tests/corelib/map_test.dart |
+++ b/tests/corelib_2/map_test.dart |
@@ -21,6 +21,8 @@ void main() { |
test(new MapView(new SplayTreeMap())); |
test(new MapBaseMap()); |
test(new MapMixinMap()); |
+ test(newJsonMap(), false); |
+ test(newJsonMapCustomReviver(), false); |
testLinkedHashMap(); |
testMapLiteral(); |
testNullValue(); |
@@ -90,6 +92,8 @@ void main() { |
testIterationOrder(new LinkedHashMap()); |
testIterationOrder(new LinkedHashMap.identity()); |
+ testIterationOrder(newJsonMap()); |
+ testIterationOrder(newJsonMapCustomReviver()); |
testOtherKeys(new SplayTreeMap<int, int>()); |
testOtherKeys( |
@@ -121,9 +125,11 @@ void main() { |
testFrom(); |
} |
-void test(Map map) { |
+void test(Map map, [bool useIntegerKeys = true]) { |
Bob Nystrom
2017/07/31 21:19:16
Nit, make useIntegerKeys a named parameter.
https
|
testDeletedElement(map); |
- testMap(map, 1, 2, 3, 4, 5, 6, 7, 8); |
+ if (useIntegerKeys) { |
+ testMap(map, 1, 2, 3, 4, 5, 6, 7, 8); |
+ } |
map.clear(); |
testMap(map, "value1", "value2", "value3", "value4", "value5", "value6", |
"value7", "value8"); |
@@ -299,33 +305,33 @@ void testMap(Map map, key1, key2, key3, key4, key5, key6, key7, key8) { |
// Test Map.addAll. |
map.clear(); |
otherMap.clear(); |
- otherMap[99] = 1; |
- otherMap[50] = 50; |
- otherMap[1] = 99; |
+ otherMap['99'] = 1; |
+ otherMap['50'] = 50; |
+ otherMap['1'] = 99; |
map.addAll(otherMap); |
Expect.equals(3, map.length); |
- Expect.equals(1, map[99]); |
- Expect.equals(50, map[50]); |
- Expect.equals(99, map[1]); |
- otherMap[50] = 42; |
+ Expect.equals(1, map['99']); |
+ Expect.equals(50, map['50']); |
+ Expect.equals(99, map['1']); |
+ otherMap['50'] = 42; |
map.addAll(new HashMap.from(otherMap)); |
Expect.equals(3, map.length); |
- Expect.equals(1, map[99]); |
- Expect.equals(42, map[50]); |
- Expect.equals(99, map[1]); |
- otherMap[99] = 7; |
+ Expect.equals(1, map['99']); |
+ Expect.equals(42, map['50']); |
+ Expect.equals(99, map['1']); |
+ otherMap['99'] = 7; |
map.addAll(new SplayTreeMap.from(otherMap)); |
Expect.equals(3, map.length); |
- Expect.equals(7, map[99]); |
- Expect.equals(42, map[50]); |
- Expect.equals(99, map[1]); |
- otherMap.remove(99); |
- map[99] = 0; |
+ Expect.equals(7, map['99']); |
+ Expect.equals(42, map['50']); |
+ Expect.equals(99, map['1']); |
+ otherMap.remove('99'); |
+ map['99'] = 0; |
map.addAll(otherMap); |
Expect.equals(3, map.length); |
- Expect.equals(0, map[99]); |
- Expect.equals(42, map[50]); |
- Expect.equals(99, map[1]); |
+ Expect.equals(0, map['99']); |
+ Expect.equals(42, map['50']); |
+ Expect.equals(99, map['1']); |
map.clear(); |
otherMap.clear(); |
map.addAll(otherMap); |
@@ -335,9 +341,9 @@ void testMap(Map map, key1, key2, key3, key4, key5, key6, key7, key8) { |
void testDeletedElement(Map map) { |
map.clear(); |
for (int i = 0; i < 100; i++) { |
- map[1] = 2; |
+ map['1'] = 2; |
testLength(1, map); |
- map.remove(1); |
+ map.remove('1'); |
testLength(0, map); |
} |
testLength(0, map); |
@@ -783,9 +789,10 @@ int myHashCode(Customer c) => c.secondId; |
bool myEquals(Customer a, Customer b) => a.secondId == b.secondId; |
void testIterationOrder(Map map) { |
- var order = [0, 6, 4, 2, 7, 9, 7, 1, 2, 5, 3]; |
+ var order = ['0', '6', '4', '2', '7', '9', '7', '1', '2', '5', '3']; |
for (int i = 0; i < order.length; i++) map[order[i]] = i; |
- Expect.listEquals(map.keys.toList(), [0, 6, 4, 2, 7, 9, 1, 5, 3]); |
+ Expect.listEquals( |
+ map.keys.toList(), ['0', '6', '4', '2', '7', '9', '1', '5', '3']); |
Expect.listEquals(map.values.toList(), [0, 1, 2, 8, 6, 5, 7, 9, 10]); |
} |
@@ -795,9 +802,6 @@ void testOtherKeys(Map<int, int> map) { |
// use the equality/comparator on incompatible objects. |
// This should not throw in either checked or unchecked mode. |
- map[0] = 0; |
- map[1] = 1; |
- map[2] = 2; |
Expect.isFalse(map.containsKey("not an int")); |
Expect.isFalse(map.containsKey(1.5)); |
Expect.isNull(map.remove("not an int")); |
@@ -909,7 +913,7 @@ class UnmodifiableMapBaseMap<K, V> extends UnmodifiableMapBase<K, V> { |
int get _modCount => 0; |
- V operator [](K key) { |
+ V operator [](Object key) { |
int index = _keys.indexOf(key); |
if (index < 0) return null; |
return _values[index]; |
@@ -923,7 +927,7 @@ abstract class Super implements Comparable {} |
abstract class Interface implements Comparable {} |
class Sub extends Super implements Interface, Comparable { |
- int compareTo(Sub other) => 0; |
+ int compareTo(dynamic other) => 0; |
int get hashCode => 0; |
bool operator ==(other) => other is Sub; |
} |