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

Unified Diff: test/cctest/compiler/test-run-jscalls.cc

Issue 484273003: Load closure from activation for building literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Load closure from activation for building literals. Created 6 years, 4 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 | « test/cctest/compiler/function-tester.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-jscalls.cc
diff --git a/test/cctest/compiler/test-run-jscalls.cc b/test/cctest/compiler/test-run-jscalls.cc
index fa7e98d5ec8178940dcb901c0f29f71115453f14..20fa16c5d1f3119384f780144cbd7c051acd5606 100644
--- a/test/cctest/compiler/test-run-jscalls.cc
+++ b/test/cctest/compiler/test-run-jscalls.cc
@@ -245,3 +245,46 @@ TEST(CallEval) {
T.CheckCall(T.Val(42), T.Val("x"), T.undefined());
}
+
+#if V8_TURBOFAN_TARGET
+
+TEST(ContextLoadedFromActivation) {
+ const char* script =
+ "var x = 42;"
+ "(function() {"
+ " return function () { return x };"
+ "})()";
+
+ // Disable context specialization.
+ FunctionTester T(script, false);
+ T.CompileFunctionInSeparateContext(
+ script,
+ [&T](v8::Handle<v8::Context> context, Handle<JSFunction> function) {
sigurds 2014/08/21 09:14:14 Look at this beautiful lambda :) I'll replace it w
+ function->set_code(T.function->code());
+ context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(function));
+ CompileRun("var x = 24;");
+ ExpectInt32("foo();", 24);
+ });
+}
+
+
+TEST(BuiltinLoadedFromActivation) {
+ const char* script =
+ "var x = 42;"
+ "(function() {"
+ " return function () { return this; };"
+ "})()";
+
+ // Disable context specialization.
+ FunctionTester T(script, false);
+ T.CompileFunctionInSeparateContext(
+ script,
+ [&T](v8::Handle<v8::Context> context, Handle<JSFunction> function) {
+ function->set_code(T.function->code());
+ context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(function));
+ CompileRun("var x = 24;");
+ ExpectObject("foo()", context->Global());
+ });
+}
+
+#endif // V8_TURBO_TARGET
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698