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

Unified Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1410853002: [Interpreter] Add support for RegExp literals. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months 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
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();
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698