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

Unified Diff: runtime/vm/object_test.cc

Issue 358723002: Add Instance::HashCode that matches hashCode. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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/vm/object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object_test.cc
===================================================================
--- runtime/vm/object_test.cc (revision 37709)
+++ runtime/vm/object_test.cc (working copy)
@@ -4090,4 +4090,27 @@
EXPECT(!a0.IsIdenticalTo(a1));
}
+
+TEST_CASE(HashCode) {
+ // Ensure C++ overrides of Instance::HashCode match the Dart implementations.
+ const char* kScript =
+ "foo() {\n"
+ " return \"foo\".hashCode;\n"
+ "}";
+
+ Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL);
+ EXPECT_VALID(h_lib);
+ Library& lib = Library::Handle();
+ lib ^= Api::UnwrapHandle(h_lib);
+ EXPECT(!lib.IsNull());
+ Dart_Handle h_result = Dart_Invoke(h_lib, NewString("foo"), 0, NULL);
+ EXPECT_VALID(h_result);
+ Integer& result = Integer::Handle();
+ result ^= Api::UnwrapHandle(h_result);
+ String& foo = String::Handle(String::New("foo"));
+ Integer& expected = Integer::Handle();
+ expected ^= foo.HashCode();
+ EXPECT(result.IsIdenticalTo(expected));
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698