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

Unified Diff: tests/corelib/expando_test.dart

Issue 24556002: Make VM Expando use identityHashCode instead of object's hashCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « runtime/lib/expando_patch.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/expando_test.dart
diff --git a/tests/corelib/expando_test.dart b/tests/corelib/expando_test.dart
index 3bff957f9185e268632acdcee4ab8ca5c30cdbd2..d55aecf95c0ac970b4622ba98a1b65096924b0aa 100644
--- a/tests/corelib/expando_test.dart
+++ b/tests/corelib/expando_test.dart
@@ -21,6 +21,7 @@ class ExpandoTest {
Expect.equals(2, visits[object]);
}
testIllegal();
+ testIdentity();
}
static visit(object) {
@@ -78,6 +79,31 @@ class ExpandoTest {
Expect.throws(() => expando[false], (exception)
=> exception is ArgumentError);
}
+
+ static testIdentity() {
+ // Expando only depends on identity of object.
+ Expando<int> expando = new Expando<int>();
+ var m1 = new Mutable(1);
+ var m2 = new Mutable(7);
+ var m3 = new Mutable(13);
+ expando[m1] = 42;
+ Expect.equals(42, expando[m1]);
+ m1.id = 37;
+ Expect.equals(42, expando[m1]);
+ expando[m2] = 37;
+ expando[m3] = 10;
+ m3.id = 1;
+ Expect.equals(42, expando[m1]);
+ Expect.equals(37, expando[m2]);
+ Expect.equals(10, expando[m3]);
+ }
}
main() => ExpandoTest.testMain();
+
+class Mutable {
+ int id;
+ Mutable(this.id);
+ int get hashCode => id;
+ bool operator==(other) => other is Mutable && other.id == id;
+}
« no previous file with comments | « runtime/lib/expando_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698