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

Unified Diff: test/cctest/test-api.cc

Issue 753373003: Add GetIdentityHash to v8::Name object API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 6 years 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 | « src/api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 0920178785e1664112f32c7c375c8c306ba7df64..a70cdbb71522873e80b9043f766650fa131b2927 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -3033,6 +3033,53 @@ THREADED_TEST(GlobalProxyIdentityHash) {
}
+TEST(SymbolIdentityHash) {
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+
+ {
+ Local<v8::Symbol> symbol = v8::Symbol::New(isolate);
+ int hash = symbol->GetIdentityHash();
+ int hash1 = symbol->GetIdentityHash();
+ CHECK_EQ(hash, hash1);
+ CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
+ int hash3 = symbol->GetIdentityHash();
+ CHECK_EQ(hash, hash3);
+ }
+
+ {
+ v8::Handle<v8::Symbol> js_symbol =
+ CompileRun("Symbol('foo')").As<v8::Symbol>();
+ int hash = js_symbol->GetIdentityHash();
+ int hash1 = js_symbol->GetIdentityHash();
+ CHECK_EQ(hash, hash1);
+ CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
+ int hash3 = js_symbol->GetIdentityHash();
+ CHECK_EQ(hash, hash3);
+ }
+}
+
+
+TEST(StringIdentityHash) {
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+
+ Local<v8::String> str = v8::String::NewFromUtf8(isolate, "str1");
+ int hash = str->GetIdentityHash();
+ int hash1 = str->GetIdentityHash();
+ CHECK_EQ(hash, hash1);
+ CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
+ int hash3 = str->GetIdentityHash();
+ CHECK_EQ(hash, hash3);
+
+ Local<v8::String> str2 = v8::String::NewFromUtf8(isolate, "str1");
+ int hash4 = str2->GetIdentityHash();
+ CHECK_EQ(hash, hash4);
+}
+
+
THREADED_TEST(SymbolProperties) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698