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

Unified Diff: tests/corelib/splay_tree_from_iterable_test.dart

Issue 710063002: Change SplayTreeMap test to not cause static type warnings, only runtime errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/splay_tree_from_iterable_test.dart
diff --git a/tests/corelib/splay_tree_from_iterable_test.dart b/tests/corelib/splay_tree_from_iterable_test.dart
index 778b0ff964e2916e9395959a8907a371e6b7d6c5..6ba1818b51ca49371c8a06bea0ef468cfd458f29 100644
--- a/tests/corelib/splay_tree_from_iterable_test.dart
+++ b/tests/corelib/splay_tree_from_iterable_test.dart
@@ -124,9 +124,14 @@ void typedTest() {
assert((isCheckedMode = true));
if (!isCheckedMode) return;
+ // Assign functions to untyped function variables.
+ Function key = (int v) => "$v";
+ Function value = (int v) => v.isOdd;
+ Function id = (int i) => i;
+
Expect.throws(() {
new SplayTreeMap<String,bool>.fromIterable(<int>[1, 2, 3],
- key: (int v) => "$v"
+ key: key
// No "value" map, defaults to identity, which returns int, not bool.
);
});
@@ -134,29 +139,29 @@ void typedTest() {
Expect.throws(() {
new SplayTreeMap<String,bool>.fromIterable(<int>[1, 2, 3],
// No "key" map, defaults to identity, which returns int, not String.
- value: (int v) => v.isOdd
+ value: value
);
});
Expect.throws(() {
new SplayTreeMap<String,bool>.fromIterable(<int>[1, 2, 3],
- key: (int v) => v, // wrong type.
- value: (int v) => v.isOdd
+ key: id, // wrong type.
+ value: value
);
});
Expect.throws(() {
new SplayTreeMap<String,bool>.fromIterable(<int>[1, 2, 3],
- key: (int v) => "$v",
- value: (int v) => v // wrong type.
+ key: key,
+ value: id // wrong type.
);
});
// But it works with explicit types when used correctly.
- Map<String, bool> map =
+ SplayTreeMap<String, bool> map =
new SplayTreeMap<String, bool>.fromIterable(<int>[1, 2, 3],
- key: (int v) => "$v",
- value: (int v) => v.isOdd);
+ key: key,
+ value: value);
Iterable<String> keys = map.keys;
Iterable<bool> values = map.values;
List<String> keyList = keys.toList();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698