Index: test/cctest/interpreter/test-interpreter.cc |
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc |
index 87379bc73684b1d4dd658160b8cc0c6341058c27..b1f21c56979c4adf462bd6f995b2112afaaf8c27 100644 |
--- a/test/cctest/interpreter/test-interpreter.cc |
+++ b/test/cctest/interpreter/test-interpreter.cc |
@@ -1644,6 +1644,35 @@ TEST(InterpreterFunctionLiteral) { |
} |
+TEST(InterpreterRegExpLiterals) { |
+ HandleAndZoneScope handles; |
+ i::Isolate* isolate = handles.main_isolate(); |
+ i::Factory* factory = isolate->factory(); |
+ |
+ std::pair<const char*, Handle<Object>> literals[5] = { |
+ std::make_pair("return /abd/.exec('cccabbdd');\n", |
+ factory->null_value()), |
+ std::make_pair("return /ab+d/.exec('cccabbdd')[0];\n", |
+ factory->NewStringFromStaticChars("abbd")), |
+ std::make_pair("return /AbC/i.exec('ssaBC')[0];\n", |
+ factory->NewStringFromStaticChars("aBC")), |
+ std::make_pair("return 'ssaBC'.match(/AbC/i)[0];\n", |
+ factory->NewStringFromStaticChars("aBC")), |
+ std::make_pair("return 'ssaBCtAbC'.match(/(AbC)/gi)[1];\n", |
+ factory->NewStringFromStaticChars("AbC")), |
+ }; |
+ |
+ for (size_t i = 0; i < arraysize(literals); i++) { |
+ std::string source(InterpreterTester::SourceForBody(literals[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(*literals[i].second)); |
+ } |
+} |
+ |
+ |
TEST(InterpreterArrayLiterals) { |
HandleAndZoneScope handles; |
i::Isolate* isolate = handles.main_isolate(); |