Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Local<v8::Symbol> symbol = v8::Symbol::New(isolate); | |
| 3042 int hash = symbol->GetIdentityHash(); | |
| 3043 int hash1 = symbol->GetIdentityHash(); | |
| 3044 CHECK_EQ(hash, hash1); | |
| 3045 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | |
| 3046 int hash3 = symbol->GetIdentityHash(); | |
| 3047 CHECK_EQ(hash, hash3); | |
|
aandrey
2014/12/01 15:49:17
can you also test symbols from JS:
v8::Handle<Val
yurys
2014/12/02 08:42:30
Done.
| |
| 3048 } | |
| 3049 | |
| 3050 | |
| 3051 TEST(StringIdentityHash) { | |
| 3052 LocalContext env; | |
| 3053 v8::Isolate* isolate = env->GetIsolate(); | |
| 3054 v8::HandleScope scope(isolate); | |
| 3055 | |
| 3056 Local<v8::String> str = v8::String::NewFromUtf8(isolate, "str1"); | |
| 3057 int hash = str->GetIdentityHash(); | |
| 3058 int hash1 = str->GetIdentityHash(); | |
| 3059 CHECK_EQ(hash, hash1); | |
| 3060 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | |
| 3061 int hash3 = str->GetIdentityHash(); | |
| 3062 CHECK_EQ(hash, hash3); | |
| 3063 | |
| 3064 Local<v8::String> str2 = v8::String::NewFromUtf8(isolate, "str1"); | |
| 3065 int hash4 = str2->GetIdentityHash(); | |
| 3066 CHECK_EQ(hash, hash4); | |
| 3067 } | |
| 3068 | |
| 3069 | |
| 3036 THREADED_TEST(SymbolProperties) { | 3070 THREADED_TEST(SymbolProperties) { |
| 3037 LocalContext env; | 3071 LocalContext env; |
| 3038 v8::Isolate* isolate = env->GetIsolate(); | 3072 v8::Isolate* isolate = env->GetIsolate(); |
| 3039 v8::HandleScope scope(isolate); | 3073 v8::HandleScope scope(isolate); |
| 3040 | 3074 |
| 3041 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 3075 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
| 3042 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); | 3076 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); |
| 3043 v8::Local<v8::Symbol> sym2 = | 3077 v8::Local<v8::Symbol> sym2 = |
| 3044 v8::Symbol::New(isolate, v8_str("my-symbol")); | 3078 v8::Symbol::New(isolate, v8_str("my-symbol")); |
| 3045 v8::Local<v8::Symbol> sym3 = | 3079 v8::Local<v8::Symbol> sym3 = |
| (...skipping 21336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 24382 v8::HandleScope scope(CcTest::isolate()); | 24416 v8::HandleScope scope(CcTest::isolate()); |
| 24383 RandomLengthOneByteResource* r = | 24417 RandomLengthOneByteResource* r = |
| 24384 new RandomLengthOneByteResource(i::String::kMaxLength); | 24418 new RandomLengthOneByteResource(i::String::kMaxLength); |
| 24385 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), r); | 24419 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), r); |
| 24386 CHECK(!str.IsEmpty()); | 24420 CHECK(!str.IsEmpty()); |
| 24387 v8::TryCatch try_catch; | 24421 v8::TryCatch try_catch; |
| 24388 v8::Local<v8::String> result = v8::String::Concat(str, str); | 24422 v8::Local<v8::String> result = v8::String::Concat(str, str); |
| 24389 CHECK(result.IsEmpty()); | 24423 CHECK(result.IsEmpty()); |
| 24390 CHECK(!try_catch.HasCaught()); | 24424 CHECK(!try_catch.HasCaught()); |
| 24391 } | 24425 } |
| OLD | NEW |