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

Unified Diff: test/cctest/compiler/test-run-bytecode-graph-builder.cc

Issue 1474103002: Re-reland "[Interpreter] Add CreateClosure to BytecodeGraphBuilder." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-bytecode-graph-builder.cc
diff --git a/test/cctest/compiler/test-run-bytecode-graph-builder.cc b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
index 7c000e60ba74ce00bd873086ed9222201b8be14c..248ff4b7ea19b4b78044af45b3e51d05f270aa33 100644
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
@@ -582,6 +582,45 @@ TEST(BytecodeGraphBuilderCallNew) {
}
+TEST(BytecodeGraphBuilderCreateClosure) {
+ HandleAndZoneScope scope;
+ Isolate* isolate = scope.main_isolate();
+ Zone* zone = scope.main_zone();
+ Factory* factory = isolate->factory();
+
+ ExpectedSnippet<0> snippets[] = {
+ {"function f() {\n"
+ " function counter() { this.count = 20; }\n"
+ " var c = new counter();\n"
+ " return c.count;\n"
+ "}; f()",
+ {factory->NewNumberFromInt(20)}},
+ {"function f() {\n"
+ " function counter(arg0) { this.count = 17; this.x = arg0; }\n"
+ " var c = new counter(6);\n"
+ " return c.count + c.x;\n"
+ "}; f()",
+ {factory->NewNumberFromInt(23)}},
+ {"function f() {\n"
+ " function counter(arg0, arg1) {\n"
+ " this.count = 17; this.x = arg0; this.y = arg1;\n"
+ " }\n"
+ " var c = new counter(3, 5);\n"
+ " return c.count + c.x + c.y;\n"
+ "}; f()",
+ {factory->NewNumberFromInt(25)}},
+ };
+
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
+ for (size_t i = 0; i < num_snippets; i++) {
+ BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet);
+ auto callable = tester.GetCallable<>();
+ Handle<Object> return_value = callable().ToHandleChecked();
+ CHECK(return_value->SameValue(*snippets[i].return_value()));
+ }
+}
+
+
TEST(BytecodeGraphBuilderCallRuntime) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698