Index: test/cctest/interpreter/test-interpreter.cc |
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc |
index e4e546ae83c735a16d41c5f4af5cce945cc8b830..ded815b9557d3eee63b850148db26e75a14bff49 100644 |
--- a/test/cctest/interpreter/test-interpreter.cc |
+++ b/test/cctest/interpreter/test-interpreter.cc |
@@ -3825,6 +3825,37 @@ TEST(InterpreterWideParametersSummation) { |
// TODO(oth): Test for..in with wide registers. |
+TEST(InterpreterDoExpression) { |
+ bool old_flag = FLAG_harmony_do_expressions; |
+ FLAG_harmony_do_expressions = true; |
+ |
+ HandleAndZoneScope handles; |
+ i::Isolate* isolate = handles.main_isolate(); |
+ Factory* factory = isolate->factory(); |
+ |
+ std::pair<const char*, Handle<Object>> do_expr[] = { |
+ {"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(do_expr); i++) { |
+ std::string source(InterpreterTester::SourceForBody(do_expr[i].first)); |
+ InterpreterTester tester(handles.main_isolate(), source.c_str()); |
+ auto callable = tester.GetCallable<>(); |
+ |
+ Handle<i::Object> return_value = callable().ToHandleChecked(); |
+ CHECK(return_value->SameValue(*do_expr[i].second)); |
+ } |
+ |
+ FLAG_harmony_do_expressions = old_flag; |
+} |
+ |
} // namespace interpreter |
} // namespace internal |
} // namespace v8 |