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

Side by Side Diff: test/cctest/test-api.cc

Issue 2085223002: Add HasOwnProperty with array indexes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 6 months 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/objects-inl.h ('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 20460 matching lines...) Expand 10 before | Expand all | Expand 10 after
20471 CHECK(object->Has(env.local(), v8_str("baz")).FromJust()); 20471 CHECK(object->Has(env.local(), v8_str("baz")).FromJust());
20472 CHECK(!object->HasOwnProperty(env.local(), v8_str("baz")).FromJust()); 20472 CHECK(!object->HasOwnProperty(env.local(), v8_str("baz")).FromJust());
20473 CHECK(object->HasOwnProperty(env.local(), v8_str("bla")).FromJust()); 20473 CHECK(object->HasOwnProperty(env.local(), v8_str("bla")).FromJust());
20474 } 20474 }
20475 { // Check named getter interceptors. 20475 { // Check named getter interceptors.
20476 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 20476 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20477 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( 20477 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
20478 HasOwnPropertyNamedPropertyGetter)); 20478 HasOwnPropertyNamedPropertyGetter));
20479 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked(); 20479 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20480 CHECK(!instance->HasOwnProperty(env.local(), v8_str("42")).FromJust()); 20480 CHECK(!instance->HasOwnProperty(env.local(), v8_str("42")).FromJust());
20481 CHECK(!instance->HasOwnProperty(env.local(), 42).FromJust());
20481 CHECK(instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust()); 20482 CHECK(instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust());
20482 CHECK(!instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust()); 20483 CHECK(!instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust());
20483 } 20484 }
20484 { // Check indexed getter interceptors. 20485 { // Check indexed getter interceptors.
20485 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 20486 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20486 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( 20487 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration(
20487 HasOwnPropertyIndexedPropertyGetter)); 20488 HasOwnPropertyIndexedPropertyGetter));
20488 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked(); 20489 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20489 CHECK(instance->HasOwnProperty(env.local(), v8_str("42")).FromJust()); 20490 CHECK(instance->HasOwnProperty(env.local(), v8_str("42")).FromJust());
20491 CHECK(instance->HasOwnProperty(env.local(), 42).FromJust());
20490 CHECK(!instance->HasOwnProperty(env.local(), v8_str("43")).FromJust()); 20492 CHECK(!instance->HasOwnProperty(env.local(), v8_str("43")).FromJust());
20493 CHECK(!instance->HasOwnProperty(env.local(), 43).FromJust());
20491 CHECK(!instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust()); 20494 CHECK(!instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust());
20492 } 20495 }
20493 { // Check named query interceptors. 20496 { // Check named query interceptors.
20494 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 20497 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20495 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( 20498 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
20496 0, 0, HasOwnPropertyNamedPropertyQuery)); 20499 0, 0, HasOwnPropertyNamedPropertyQuery));
20497 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked(); 20500 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20498 CHECK(instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust()); 20501 CHECK(instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust());
20499 CHECK(!instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust()); 20502 CHECK(!instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust());
20500 } 20503 }
20501 { // Check indexed query interceptors. 20504 { // Check indexed query interceptors.
20502 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 20505 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20503 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( 20506 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration(
20504 0, 0, HasOwnPropertyIndexedPropertyQuery)); 20507 0, 0, HasOwnPropertyIndexedPropertyQuery));
20505 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked(); 20508 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20506 CHECK(instance->HasOwnProperty(env.local(), v8_str("42")).FromJust()); 20509 CHECK(instance->HasOwnProperty(env.local(), v8_str("42")).FromJust());
20510 CHECK(instance->HasOwnProperty(env.local(), 42).FromJust());
20507 CHECK(!instance->HasOwnProperty(env.local(), v8_str("41")).FromJust()); 20511 CHECK(!instance->HasOwnProperty(env.local(), v8_str("41")).FromJust());
20512 CHECK(!instance->HasOwnProperty(env.local(), 41).FromJust());
20508 } 20513 }
20509 { // Check callbacks. 20514 { // Check callbacks.
20510 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 20515 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20511 templ->SetAccessor(v8_str("foo"), HasOwnPropertyAccessorGetter); 20516 templ->SetAccessor(v8_str("foo"), HasOwnPropertyAccessorGetter);
20512 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked(); 20517 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20513 CHECK(instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust()); 20518 CHECK(instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust());
20514 CHECK(!instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust()); 20519 CHECK(!instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust());
20515 } 20520 }
20516 { // Check that query wins on disagreement. 20521 { // Check that query wins on disagreement.
20517 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); 20522 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
(...skipping 4820 matching lines...) Expand 10 before | Expand all | Expand 10 after
25338 } 25343 }
25339 25344
25340 TEST(PrivateForApiIsNumber) { 25345 TEST(PrivateForApiIsNumber) {
25341 LocalContext context; 25346 LocalContext context;
25342 v8::Isolate* isolate = CcTest::isolate(); 25347 v8::Isolate* isolate = CcTest::isolate();
25343 v8::HandleScope scope(isolate); 25348 v8::HandleScope scope(isolate);
25344 25349
25345 // Shouldn't crash. 25350 // Shouldn't crash.
25346 v8::Private::ForApi(isolate, v8_str("42")); 25351 v8::Private::ForApi(isolate, v8_str("42"));
25347 } 25352 }
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698