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 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 | 1283 |
1284 | 1284 |
1285 THREADED_TEST(HiddenProperties) { | 1285 THREADED_TEST(HiddenProperties) { |
1286 v8::HandleScope scope; | 1286 v8::HandleScope scope; |
1287 LocalContext env; | 1287 LocalContext env; |
1288 | 1288 |
1289 v8::Local<v8::Object> obj = v8::Object::New(); | 1289 v8::Local<v8::Object> obj = v8::Object::New(); |
1290 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 1290 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
1291 v8::Local<v8::String> empty = v8_str(""); | 1291 v8::Local<v8::String> empty = v8_str(""); |
1292 v8::Local<v8::String> prop_name = v8_str("prop_name"); | 1292 v8::Local<v8::String> prop_name = v8_str("prop_name"); |
1293 | 1293 |
1294 i::Heap::CollectAllGarbage(); | 1294 i::Heap::CollectAllGarbage(); |
1295 | 1295 |
1296 CHECK(obj->SetHiddenValue(key, v8::Integer::New(1503))); | 1296 CHECK(obj->SetHiddenValue(key, v8::Integer::New(1503))); |
1297 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); | 1297 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); |
1298 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); | 1298 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); |
1299 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1299 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
1300 | 1300 |
1301 i::Heap::CollectAllGarbage(); | 1301 i::Heap::CollectAllGarbage(); |
1302 | 1302 |
1303 // Make sure we do not find the hidden property. | 1303 // Make sure we do not find the hidden property. |
1304 CHECK(!obj->Has(empty)); | 1304 CHECK(!obj->Has(empty)); |
1305 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1305 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
1306 CHECK(obj->Get(empty)->IsUndefined()); | 1306 CHECK(obj->Get(empty)->IsUndefined()); |
1307 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1307 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
1308 CHECK(obj->Set(empty, v8::Integer::New(2003))); | 1308 CHECK(obj->Set(empty, v8::Integer::New(2003))); |
1309 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1309 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
1310 CHECK_EQ(2003, obj->Get(empty)->Int32Value()); | 1310 CHECK_EQ(2003, obj->Get(empty)->Int32Value()); |
1311 | 1311 |
1312 i::Heap::CollectAllGarbage(); | 1312 i::Heap::CollectAllGarbage(); |
1313 | 1313 |
1314 // Add another property and delete it afterwards to force the object in | 1314 // Add another property and delete it afterwards to force the object in |
1315 // slow case. | 1315 // slow case. |
1316 CHECK(obj->Set(prop_name, v8::Integer::New(2008))); | 1316 CHECK(obj->Set(prop_name, v8::Integer::New(2008))); |
1317 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1317 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
1318 CHECK_EQ(2008, obj->Get(prop_name)->Int32Value()); | 1318 CHECK_EQ(2008, obj->Get(prop_name)->Int32Value()); |
1319 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1319 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
1320 CHECK(obj->Delete(prop_name)); | 1320 CHECK(obj->Delete(prop_name)); |
1321 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1321 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
1322 | 1322 |
1323 i::Heap::CollectAllGarbage(); | 1323 i::Heap::CollectAllGarbage(); |
1324 | 1324 |
1325 CHECK(obj->DeleteHiddenValue(key)); | 1325 CHECK(obj->DeleteHiddenValue(key)); |
1326 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 1326 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
1327 } | 1327 } |
1328 | 1328 |
1329 | 1329 |
1330 THREADED_TEST(External) { | 1330 THREADED_TEST(External) { |
1331 v8::HandleScope scope; | 1331 v8::HandleScope scope; |
1332 int x = 3; | 1332 int x = 3; |
(...skipping 4569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5902 Local<v8::Object> clone = obj->Clone(); | 5902 Local<v8::Object> clone = obj->Clone(); |
5903 CHECK_EQ(v8_str("hello"), clone->Get(v8_str("alpha"))); | 5903 CHECK_EQ(v8_str("hello"), clone->Get(v8_str("alpha"))); |
5904 CHECK_EQ(v8::Integer::New(123), clone->Get(v8_str("beta"))); | 5904 CHECK_EQ(v8::Integer::New(123), clone->Get(v8_str("beta"))); |
5905 CHECK_EQ(v8_str("cloneme"), clone->Get(v8_str("gamma"))); | 5905 CHECK_EQ(v8_str("cloneme"), clone->Get(v8_str("gamma"))); |
5906 | 5906 |
5907 // Set a property on the clone, verify each object. | 5907 // Set a property on the clone, verify each object. |
5908 clone->Set(v8_str("beta"), v8::Integer::New(456)); | 5908 clone->Set(v8_str("beta"), v8::Integer::New(456)); |
5909 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta"))); | 5909 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta"))); |
5910 CHECK_EQ(v8::Integer::New(456), clone->Get(v8_str("beta"))); | 5910 CHECK_EQ(v8::Integer::New(456), clone->Get(v8_str("beta"))); |
5911 } | 5911 } |
OLD | NEW |