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 9a01eda0e109a6241c9ae63ea0cd517238990dc8..a888d5ccdbe23c8dacadea7912a67fd54cac400d 100644 |
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
@@ -2426,6 +2426,39 @@ TEST(JumpWithConstantsAndWideConstants) { |
} |
} |
+TEST(BytecodeGraphBuilderDoExpressions) { |
+ bool old_flag = FLAG_harmony_do_expressions; |
+ FLAG_harmony_do_expressions = true; |
+ |
+ HandleAndZoneScope scope; |
+ Isolate* isolate = scope.main_isolate(); |
+ Zone* zone = scope.main_zone(); |
+ Factory* factory = isolate->factory(); |
+ ExpectedSnippet<0> snippets[] = { |
+ {"var a = do {}; return a;", {factory->undefined_value()}}, |
+ {"var a = do { var x = 100; }; return a;", {factory->undefined_value()}}, |
+ {"var a = do { var x = 100; }; return a;", {factory->undefined_value()}}, |
+ {"var a = do { var x = 100; x++; }; return a;", |
+ {handle(Smi::FromInt(100), isolate)}}, |
+ {"var i = 0; for (; i < 5;) { i = do { if (i == 3) { break; }; i + 1; }};" |
+ "return i;", |
+ {handle(Smi::FromInt(3), 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())); |
+ } |
+ |
+ FLAG_harmony_do_expressions = old_flag; |
+} |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |