Index: tests/corelib/map_test.dart |
diff --git a/tests/corelib/map_test.dart b/tests/corelib/map_test.dart |
index 79d1ace519b3fb3b0cfada9be45aefa09e513916..dff5e618c8dbf4c94dcd0481fba1586f5dec45f9 100644 |
--- a/tests/corelib/map_test.dart |
+++ b/tests/corelib/map_test.dart |
@@ -392,13 +392,27 @@ void testNullValue() { |
} |
void testTypes() { |
- Map<int, dynamic> map; |
- testMap(Map map) { |
- map[42] = "text"; |
- map[43] = "text"; |
- map[42] = "text"; |
- map.remove(42); |
- map[42] = "text"; |
+ testMap(Map<num, String> map) { |
+ Expect.isTrue(map is Map<num, String>); |
+ Expect.isTrue(map is! Map<String, dynamic>); |
+ Expect.isTrue(map is! Map<dynamic, int>); |
+ |
+ // Use with properly typed keys and values. |
+ map[42] = "text1"; |
+ map[43] = "text2"; |
+ map[42] = "text3"; |
+ Expect.equals("text3", map.remove(42)); |
+ Expect.equals(null, map[42]); |
+ map[42] = "text4"; |
+ |
+ // Ensure that "containsKey", "containsValue" and "remove" |
+ // accepts any object. |
+ for (var object in [true, null, new Object()]) { |
+ Expect.isFalse(map.containsKey(object)); |
+ Expect.isFalse(map.containsValue(object)); |
+ Expect.isNull(map.remove(object)); |
+ Expect.isNull(map[object]); |
+ } |
} |
testMap(new HashMap<int, String>()); |
testMap(new LinkedHashMap<int, String>()); |