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 92b2896a52a9234c92fbbdc20cddb50f340c847c..aa640de08a678cdae96d71d6bab5b132765de1a5 100644 |
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
@@ -2632,6 +2632,43 @@ TEST(BytecodeGraphBuilderDoExpressions) { |
FLAG_harmony_do_expressions = old_flag; |
} |
+TEST(BytecodeGraphBuilderWithStatement) { |
+ HandleAndZoneScope scope; |
+ Isolate* isolate = scope.main_isolate(); |
+ Zone* zone = scope.main_zone(); |
+ |
+ ExpectedSnippet<0> snippets[] = { |
+ {"with({x:42}) return x;", {handle(Smi::FromInt(42), isolate)}}, |
+ {"with({}) { var y = 10; return y;}", |
+ {handle(Smi::FromInt(10), isolate)}}, |
+ {"var y = {x:42};" |
+ " function inner() {" |
+ " var x = 20;" |
+ " with(y) return x;" |
+ "}" |
+ "return inner();", |
+ {handle(Smi::FromInt(42), isolate)}}, |
+ {"var y = {x:42};" |
+ " function inner(o) {" |
+ " var x = 20;" |
+ " with(o) return x;" |
+ "}" |
+ "return inner(y);", |
+ {handle(Smi::FromInt(42), isolate)}}, |
+ }; |
+ |
+ for (size_t i = 0; i < arraysize(snippets); i++) { |
+ ScopedVector<char> script(1024); |
+ SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, |
+ snippets[i].code_snippet, kFunctionName); |
+ |
+ BytecodeGraphTester tester(isolate, zone, script.start()); |
+ auto callable = tester.GetCallable<>(); |
+ Handle<Object> return_value = callable().ToHandleChecked(); |
+ CHECK(return_value->SameValue(*snippets[i].return_value())); |
+ } |
+} |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |