| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 1248 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
| 1249 instance_templ->SetInternalFieldCount(1); | 1249 instance_templ->SetInternalFieldCount(1); |
| 1250 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); | 1250 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); |
| 1251 CHECK_EQ(1, obj->InternalFieldCount()); | 1251 CHECK_EQ(1, obj->InternalFieldCount()); |
| 1252 CHECK(obj->GetInternalField(0)->IsUndefined()); | 1252 CHECK(obj->GetInternalField(0)->IsUndefined()); |
| 1253 obj->SetInternalField(0, v8_num(17)); | 1253 obj->SetInternalField(0, v8_num(17)); |
| 1254 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value()); | 1254 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value()); |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 | 1257 |
| 1258 THREADED_TEST(IdentityHash) { |
| 1259 v8::HandleScope scope; |
| 1260 LocalContext env; |
| 1261 |
| 1262 Local<v8::Object> obj = v8::Object::New(); |
| 1263 int hash = obj->GetIdentityHash(); |
| 1264 int hash1 = obj->GetIdentityHash(); |
| 1265 CHECK_EQ(hash, hash1); |
| 1266 int hash2 = v8::Object::New()->GetIdentityHash(); |
| 1267 CHECK_NE(hash, hash2); |
| 1268 i::Heap::CollectAllGarbage(); |
| 1269 int hash3 = v8::Object::New()->GetIdentityHash(); |
| 1270 CHECK_NE(hash, hash3); |
| 1271 int hash4 = obj->GetIdentityHash(); |
| 1272 CHECK_EQ(hash, hash4); |
| 1273 } |
| 1274 |
| 1275 |
| 1276 THREADED_TEST(HiddenProperties) { |
| 1277 v8::HandleScope scope; |
| 1278 LocalContext env; |
| 1279 |
| 1280 v8::Local<v8::Object> obj = v8::Object::New(); |
| 1281 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| 1282 CHECK(obj->SetHiddenValue(key, v8::Integer::New(1503))); |
| 1283 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); |
| 1284 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); |
| 1285 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 1286 CHECK(obj->DeleteHiddenValue(key)); |
| 1287 CHECK(obj->GetHiddenValue(key)->IsUndefined()); |
| 1288 } |
| 1289 |
| 1290 |
| 1258 THREADED_TEST(External) { | 1291 THREADED_TEST(External) { |
| 1259 v8::HandleScope scope; | 1292 v8::HandleScope scope; |
| 1260 int x = 3; | 1293 int x = 3; |
| 1261 Local<v8::External> ext = v8::External::New(&x); | 1294 Local<v8::External> ext = v8::External::New(&x); |
| 1262 LocalContext env; | 1295 LocalContext env; |
| 1263 env->Global()->Set(v8_str("ext"), ext); | 1296 env->Global()->Set(v8_str("ext"), ext); |
| 1264 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); | 1297 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); |
| 1265 v8::Handle<v8::External> reext = v8::Handle<v8::External>::Cast(reext_obj); | 1298 v8::Handle<v8::External> reext = v8::Handle<v8::External>::Cast(reext_obj); |
| 1266 int* ptr = static_cast<int*>(reext->Value()); | 1299 int* ptr = static_cast<int*>(reext->Value()); |
| 1267 CHECK_EQ(x, 3); | 1300 CHECK_EQ(x, 3); |
| (...skipping 4563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5831 CHECK_EQ(v8_str("hello"), clone->Get(v8_str("alpha"))); | 5864 CHECK_EQ(v8_str("hello"), clone->Get(v8_str("alpha"))); |
| 5832 CHECK_EQ(v8::Integer::New(123), clone->Get(v8_str("beta"))); | 5865 CHECK_EQ(v8::Integer::New(123), clone->Get(v8_str("beta"))); |
| 5833 CHECK_EQ(v8_str("cloneme"), clone->Get(v8_str("gamma"))); | 5866 CHECK_EQ(v8_str("cloneme"), clone->Get(v8_str("gamma"))); |
| 5834 | 5867 |
| 5835 // Set a property on the clone, verify each object. | 5868 // Set a property on the clone, verify each object. |
| 5836 clone->Set(v8_str("beta"), v8::Integer::New(456)); | 5869 clone->Set(v8_str("beta"), v8::Integer::New(456)); |
| 5837 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta"))); | 5870 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta"))); |
| 5838 CHECK_EQ(v8::Integer::New(456), clone->Get(v8_str("beta"))); | 5871 CHECK_EQ(v8::Integer::New(456), clone->Get(v8_str("beta"))); |
| 5839 } | 5872 } |
| 5840 | 5873 |
| OLD | NEW |