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

Unified Diff: test/cctest/test-api.cc

Issue 12314081: Speed up non-interceptor case of Object.getOwnPropertyNames (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Simplify patch Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 7dd9fc7889d8e2806a763b5251f2b4d13a71b2a5..cf9522486cb051913ea84767130046f9551e8362 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -7554,9 +7554,18 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) {
}
+static v8::Handle<v8::Array> IndexedPropertyEnumerator(const AccessorInfo&) {
+ v8::Handle<v8::Array> result = v8::Array::New(2);
+ result->Set(0, v8::Integer::New(7));
+ result->Set(1, v8::Object::New());
+ return result;
+}
+
+
static v8::Handle<v8::Array> NamedPropertyEnumerator(const AccessorInfo& info) {
- v8::Handle<v8::Array> result = v8::Array::New(1);
+ v8::Handle<v8::Array> result = v8::Array::New(2);
result->Set(0, v8_str("x"));
+ result->Set(1, v8::Object::New());
return result;
}
@@ -7565,7 +7574,10 @@ THREADED_TEST(GetOwnPropertyNamesWithInterceptor) {
v8::HandleScope handle_scope;
v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New();
+ obj_template->Set(v8_str("7"), v8::Integer::New(7));
obj_template->Set(v8_str("x"), v8::Integer::New(42));
+ obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL,
+ IndexedPropertyEnumerator);
obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL,
NamedPropertyEnumerator);
@@ -7573,9 +7585,17 @@ THREADED_TEST(GetOwnPropertyNamesWithInterceptor) {
v8::Handle<v8::Object> global = context->Global();
global->Set(v8_str("object"), obj_template->NewInstance());
- v8::Handle<Value> value =
- CompileRun("Object.getOwnPropertyNames(object).join(',')");
- CHECK_EQ(v8_str("x"), value);
+ v8::Handle<v8::Value> result =
+ CompileRun("Object.getOwnPropertyNames(object)");
+ CHECK(result->IsArray());
+ v8::Handle<v8::Array> result_array = v8::Handle<v8::Array>::Cast(result);
+ CHECK_EQ(3, result_array->Length());
+ CHECK(result_array->Get(0)->IsString());
+ CHECK(result_array->Get(1)->IsString());
+ CHECK(result_array->Get(2)->IsString());
+ CHECK_EQ(v8_str("7"), result_array->Get(0));
+ CHECK_EQ(v8_str("[object Object]"), result_array->Get(1));
+ CHECK_EQ(v8_str("x"), result_array->Get(2));
}
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698