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

Unified Diff: tests/corelib/map_test.dart

Issue 1360053003: Fix some cases where Map.containsValue did not accept Object as argument. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/collection/splay_tree.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>());
« no previous file with comments | « sdk/lib/collection/splay_tree.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698