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

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

Issue 1396693003: [Interpreter] Add function literal support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_newcontext
Patch Set: Make CreateClosure a bytecode Created 5 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
Index: test/cctest/interpreter/test-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index 7343d0818269cf8865a0cb32fcc52094e06b861b..bed394b1f3ca5d5fa977b203d5b8be9952752ba1 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -1553,3 +1553,20 @@ TEST(InterpreterCallRuntime) {
Handle<Object> return_val = callable().ToHandleChecked();
CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(55));
}
+
+
+TEST(InterpreterFunctionLiteral) {
+ HandleAndZoneScope handles;
+
+ // Test calling a function literal.
+ std::string source(
+ "function " + InterpreterTester::function_name() + "(a) {\n"
+ " return (function(x){ return x + 2; })(a);\n"
+ "}");
+ InterpreterTester tester(handles.main_isolate(), source.c_str());
+ auto callable = tester.GetCallable<Handle<Object>>();
+
+ Handle<i::Object> return_val = callable(
+ Handle<Smi>(Smi::FromInt(3), handles.main_isolate())).ToHandleChecked();
+ CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(5));
+}

Powered by Google App Engine
This is Rietveld 408576698