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

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: Review comments 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 fa9f89128b8ea1b094c2f6417f5c05ab1cfc427f..188b3e61d99c5f8aef53684ba6eeff20819e06ac 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -1620,3 +1620,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));
+}
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698