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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3015 matching lines...) Expand 10 before | Expand all | Expand 10 after
3026 CHECK_EQ(hash1, hash2); 3026 CHECK_EQ(hash1, hash2);
3027 { 3027 {
3028 // Re-attach global proxy to a new context, hash should stay the same. 3028 // Re-attach global proxy to a new context, hash should stay the same.
3029 LocalContext env2(NULL, Handle<ObjectTemplate>(), global_proxy); 3029 LocalContext env2(NULL, Handle<ObjectTemplate>(), global_proxy);
3030 int hash3 = global_proxy->GetIdentityHash(); 3030 int hash3 = global_proxy->GetIdentityHash();
3031 CHECK_EQ(hash1, hash3); 3031 CHECK_EQ(hash1, hash3);
3032 } 3032 }
3033 } 3033 }
3034 3034
3035 3035
3036 TEST(SymbolIdentityHash) {
3037 LocalContext env;
3038 v8::Isolate* isolate = env->GetIsolate();
3039 v8::HandleScope scope(isolate);
3040
3041 {
3042 Local<v8::Symbol> symbol = v8::Symbol::New(isolate);
3043 int hash = symbol->GetIdentityHash();
3044 int hash1 = symbol->GetIdentityHash();
3045 CHECK_EQ(hash, hash1);
3046 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
3047 int hash3 = symbol->GetIdentityHash();
3048 CHECK_EQ(hash, hash3);
3049 }
3050
3051 {
3052 v8::Handle<v8::Symbol> js_symbol =
3053 CompileRun("Symbol('foo')").As<v8::Symbol>();
3054 int hash = js_symbol->GetIdentityHash();
3055 int hash1 = js_symbol->GetIdentityHash();
3056 CHECK_EQ(hash, hash1);
3057 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
3058 int hash3 = js_symbol->GetIdentityHash();
3059 CHECK_EQ(hash, hash3);
3060 }
3061 }
3062
3063
3064 TEST(StringIdentityHash) {
3065 LocalContext env;
3066 v8::Isolate* isolate = env->GetIsolate();
3067 v8::HandleScope scope(isolate);
3068
3069 Local<v8::String> str = v8::String::NewFromUtf8(isolate, "str1");
3070 int hash = str->GetIdentityHash();
3071 int hash1 = str->GetIdentityHash();
3072 CHECK_EQ(hash, hash1);
3073 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
3074 int hash3 = str->GetIdentityHash();
3075 CHECK_EQ(hash, hash3);
3076
3077 Local<v8::String> str2 = v8::String::NewFromUtf8(isolate, "str1");
3078 int hash4 = str2->GetIdentityHash();
3079 CHECK_EQ(hash, hash4);
3080 }
3081
3082
3036 THREADED_TEST(SymbolProperties) { 3083 THREADED_TEST(SymbolProperties) {
3037 LocalContext env; 3084 LocalContext env;
3038 v8::Isolate* isolate = env->GetIsolate(); 3085 v8::Isolate* isolate = env->GetIsolate();
3039 v8::HandleScope scope(isolate); 3086 v8::HandleScope scope(isolate);
3040 3087
3041 v8::Local<v8::Object> obj = v8::Object::New(isolate); 3088 v8::Local<v8::Object> obj = v8::Object::New(isolate);
3042 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); 3089 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate);
3043 v8::Local<v8::Symbol> sym2 = 3090 v8::Local<v8::Symbol> sym2 =
3044 v8::Symbol::New(isolate, v8_str("my-symbol")); 3091 v8::Symbol::New(isolate, v8_str("my-symbol"));
3045 v8::Local<v8::Symbol> sym3 = 3092 v8::Local<v8::Symbol> sym3 =
(...skipping 21336 matching lines...) Expand 10 before | Expand all | Expand 10 after
24382 v8::HandleScope scope(CcTest::isolate()); 24429 v8::HandleScope scope(CcTest::isolate());
24383 RandomLengthOneByteResource* r = 24430 RandomLengthOneByteResource* r =
24384 new RandomLengthOneByteResource(i::String::kMaxLength); 24431 new RandomLengthOneByteResource(i::String::kMaxLength);
24385 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), r); 24432 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), r);
24386 CHECK(!str.IsEmpty()); 24433 CHECK(!str.IsEmpty());
24387 v8::TryCatch try_catch; 24434 v8::TryCatch try_catch;
24388 v8::Local<v8::String> result = v8::String::Concat(str, str); 24435 v8::Local<v8::String> result = v8::String::Concat(str, str);
24389 CHECK(result.IsEmpty()); 24436 CHECK(result.IsEmpty());
24390 CHECK(!try_catch.HasCaught()); 24437 CHECK(!try_catch.HasCaught());
24391 } 24438 }
OLDNEW
« 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