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

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

Issue 3595013: Do not shortcut union of keys if lhs is empty. (Closed)
Patch Set: Addressing Kasper's comments Created 10 years, 2 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/objects.cc ('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 12eabbd7b4eb3135bda9bdcee82492cc8ba2fb85..af50d3d0eede84f7cda0810b23df8272f46293e9 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -11727,3 +11727,31 @@ TEST(RegExp) {
context->Global()->Set(v8_str("ex"), try_catch.Exception());
ExpectTrue("ex instanceof SyntaxError");
}
+
+
+static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo& info ) {
+ return v8_str("42!");
+}
+
+
+static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo& info) {
+ v8::Handle<v8::Array> result = v8::Array::New();
+ result->Set(0, v8_str("universalAnswer"));
+ return result;
+}
+
+
+TEST(NamedEnumeratorAndForIn) {
+ v8::HandleScope handle_scope;
+ LocalContext context;
+ v8::Context::Scope context_scope(context.local());
+
+ v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
+ tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
+ context->Global()->Set(v8_str("o"), tmpl->NewInstance());
+ v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
+ "var result = []; for (var k in o) result.push(k); result"));
+ CHECK_EQ(1, result->Length());
+ CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
+}
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698