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

Unified Diff: tests/corelib/hash_set_test.dart

Issue 26832002: Add Set.lookup method to get the instance in the set. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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/html/html_common/css_class_set.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/hash_set_test.dart
diff --git a/tests/corelib/hash_set_test.dart b/tests/corelib/hash_set_test.dart
index 06286100d0bbc48bb82adbb120f10a584fb84d8c..835e300cb5228f9e0ddeda21dcf93b2e152ccd33 100644
--- a/tests/corelib/hash_set_test.dart
+++ b/tests/corelib/hash_set_test.dart
@@ -218,6 +218,39 @@ testSet(Set newSet(), Set newSetFrom(Iterable from)) {
Expect.isFalse(set.contains(2));
Expect.isTrue(set.contains(3));
}
+
+ { // Test lookup
+ Set set = newSet();
+ var m1a = new Mutable(1);
+ var m1b = new Mutable(1);
+ var m2a = new Mutable(2);
+ var m2b = new Mutable(2);
+ Expect.isNull(set.lookup(m1a));
+ Expect.isNull(set.lookup(m1b));
+ set.add(m1a);
+ Expect.identical(m1a, set.lookup(m1a));
+ Expect.identical(m1a, set.lookup(m1b));
+
+ Expect.isNull(set.lookup(m2a));
+ Expect.isNull(set.lookup(m2b));
+ set.add(m2a);
+ Expect.identical(m2a, set.lookup(m2a));
+ Expect.identical(m2a, set.lookup(m2b));
+
+ set.add(m2b); // Adding doesn't change element.
+ Expect.identical(m2a, set.lookup(m2a));
+ Expect.identical(m2a, set.lookup(m2b));
+
+ set.remove(m1a);
+ set.add(m1b);
+ Expect.identical(m1b, set.lookup(m1a));
+ Expect.identical(m1b, set.lookup(m1b));
+
+ set.add(1);
+ Expect.identical(1, set.lookup(1.0));
+ set.add(-0.0);
+ Expect.identical(-0.0, set.lookup(0.0));
+ }
}
@@ -259,6 +292,9 @@ void testIdentitySet(Set create()) {
set.remove(m3);
Expect.isFalse(set.contains(m3));
Expect.isTrue(set.contains(m1));
+
+ Expect.identical(m1, set.lookup(m1));
+ Expect.identical(null, set.lookup(m3));
}
« no previous file with comments | « sdk/lib/html/html_common/css_class_set.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698