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

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

Issue 1418963009: Experimental support for RegExp lookbehind. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix arm64 debug code assertion Created 5 years, 1 month 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
« no previous file with comments | « src/regexp/x64/regexp-macro-assembler-x64.cc ('k') | test/mjsunit/harmony/regexp-lookbehind.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-regexp.cc
diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc
index 2e236c20f3188fcde73cc1b0a7d71cabf8cc8c18..21d5ad1fba477fb5ad142d0185d9bbb685ab0d0d 100644
--- a/test/cctest/test-regexp.cc
+++ b/test/cctest/test-regexp.cc
@@ -159,7 +159,10 @@ static MinMaxPair CheckMinMaxMatch(const char* input) {
CHECK_EQ(max, min_max.max_match); \
}
-TEST(Parser) {
+
+void TestRegExpParser(bool lookbehind) {
+ FLAG_harmony_regexp_lookbehind = lookbehind;
+
CHECK_PARSE_ERROR("?");
CheckParseEq("abc", "'abc'");
@@ -191,6 +194,13 @@ TEST(Parser) {
CheckParseEq("foo|(bar|baz)|quux", "(| 'foo' (^ (| 'bar' 'baz')) 'quux')");
CheckParseEq("foo(?=bar)baz", "(: 'foo' (-> + 'bar') 'baz')");
CheckParseEq("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')");
+ if (lookbehind) {
+ CheckParseEq("foo(?<=bar)baz", "(: 'foo' (<- + 'bar') 'baz')");
+ CheckParseEq("foo(?<!bar)baz", "(: 'foo' (<- - 'bar') 'baz')");
+ } else {
+ CHECK_PARSE_ERROR("foo(?<=bar)baz");
+ CHECK_PARSE_ERROR("foo(?<!bar)baz");
+ }
CheckParseEq("()", "(^ %)");
CheckParseEq("(?=)", "(-> + %)");
CheckParseEq("[]", "^[\\x00-\\uffff]"); // Doesn't compile on windows
@@ -267,9 +277,16 @@ TEST(Parser) {
CheckParseEq("(?=a){1,10}a", "(: (-> + 'a') 'a')");
CheckParseEq("(?=a){9,10}a", "(: (-> + 'a') 'a')");
CheckParseEq("(?!a)?a", "'a'");
- CheckParseEq("\\1(a)", "(^ 'a')");
+ CheckParseEq("\\1(a)", "(: (<- 1) (^ 'a'))");
CheckParseEq("(?!(a))\\1", "(: (-> - (^ 'a')) (<- 1))");
- CheckParseEq("(?!\\1(a\\1)\\1)\\1", "(: (-> - (: (^ 'a') (<- 1))) (<- 1))");
+ CheckParseEq("(?!\\1(a\\1)\\1)\\1",
+ "(: (-> - (: (<- 1) (^ 'a') (<- 1))) (<- 1))");
+ CheckParseEq("\\1\\2(a(?:\\1(b\\1\\2))\\2)\\1",
+ "(: (<- 1) (<- 2) (^ (: 'a' (^ 'b') (<- 2))) (<- 1))");
+ if (lookbehind) {
+ CheckParseEq("\\1\\2(a(?<=\\1(b\\1\\2))\\2)\\1",
+ "(: (<- 1) (<- 2) (^ (: 'a' (<- + (^ 'b')) (<- 2))) (<- 1))");
+ }
CheckParseEq("[\\0]", "[\\x00]");
CheckParseEq("[\\11]", "[\\x09]");
CheckParseEq("[\\11a]", "[\\x09 a]");
@@ -400,6 +417,16 @@ TEST(Parser) {
}
+TEST(ParserWithLookbehind) {
+ TestRegExpParser(true); // Lookbehind enabled.
+}
+
+
+TEST(ParserWithoutLookbehind) {
+ TestRegExpParser(true); // Lookbehind enabled.
+}
+
+
TEST(ParserRegression) {
CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])");
CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')");
@@ -790,7 +817,7 @@ TEST(MacroAssemblerNativeSimple) {
Label fail, backtrack;
m.PushBacktrack(&fail);
- m.CheckNotAtStart(NULL);
+ m.CheckNotAtStart(0, NULL);
m.LoadCurrentCharacter(2, NULL);
m.CheckNotCharacter('o', NULL);
m.LoadCurrentCharacter(1, NULL, false);
@@ -857,7 +884,7 @@ TEST(MacroAssemblerNativeSimpleUC16) {
Label fail, backtrack;
m.PushBacktrack(&fail);
- m.CheckNotAtStart(NULL);
+ m.CheckNotAtStart(0, NULL);
m.LoadCurrentCharacter(2, NULL);
m.CheckNotCharacter('o', NULL);
m.LoadCurrentCharacter(1, NULL, false);
@@ -973,12 +1000,12 @@ TEST(MacroAssemblerNativeBackReferenceLATIN1) {
m.AdvanceCurrentPosition(2);
m.WriteCurrentPositionToRegister(1, 0);
Label nomatch;
- m.CheckNotBackReference(0, &nomatch);
+ m.CheckNotBackReference(0, false, &nomatch);
m.Fail();
m.Bind(&nomatch);
m.AdvanceCurrentPosition(2);
Label missing_match;
- m.CheckNotBackReference(0, &missing_match);
+ m.CheckNotBackReference(0, false, &missing_match);
m.WriteCurrentPositionToRegister(2, 0);
m.Succeed();
m.Bind(&missing_match);
@@ -1023,12 +1050,12 @@ TEST(MacroAssemblerNativeBackReferenceUC16) {
m.AdvanceCurrentPosition(2);
m.WriteCurrentPositionToRegister(1, 0);
Label nomatch;
- m.CheckNotBackReference(0, &nomatch);
+ m.CheckNotBackReference(0, false, &nomatch);
m.Fail();
m.Bind(&nomatch);
m.AdvanceCurrentPosition(2);
Label missing_match;
- m.CheckNotBackReference(0, &missing_match);
+ m.CheckNotBackReference(0, false, &missing_match);
m.WriteCurrentPositionToRegister(2, 0);
m.Succeed();
m.Bind(&missing_match);
@@ -1073,7 +1100,7 @@ TEST(MacroAssemblernativeAtStart) {
0);
Label not_at_start, newline, fail;
- m.CheckNotAtStart(&not_at_start);
+ m.CheckNotAtStart(0, &not_at_start);
// Check that prevchar = '\n' and current = 'f'.
m.CheckCharacter('\n', &newline);
m.Bind(&fail);
@@ -1138,16 +1165,16 @@ TEST(MacroAssemblerNativeBackRefNoCase) {
m.WriteCurrentPositionToRegister(2, 0);
m.AdvanceCurrentPosition(3);
m.WriteCurrentPositionToRegister(3, 0);
- m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC".
- m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC".
+ m.CheckNotBackReferenceIgnoreCase(2, false, &fail); // Match "AbC".
+ m.CheckNotBackReferenceIgnoreCase(2, false, &fail); // Match "ABC".
Label expected_fail;
- m.CheckNotBackReferenceIgnoreCase(2, &expected_fail);
+ m.CheckNotBackReferenceIgnoreCase(2, false, &expected_fail);
m.Bind(&fail);
m.Fail();
m.Bind(&expected_fail);
m.AdvanceCurrentPosition(3); // Skip "xYz"
- m.CheckNotBackReferenceIgnoreCase(2, &succ);
+ m.CheckNotBackReferenceIgnoreCase(2, false, &succ);
m.Fail();
m.Bind(&succ);
@@ -1339,7 +1366,7 @@ TEST(MacroAssemblerNativeLotsOfRegisters) {
m.WriteCurrentPositionToRegister(0, 0);
m.WriteCurrentPositionToRegister(1, 1);
Label done;
- m.CheckNotBackReference(0, &done); // Performs a system-stack push.
+ m.CheckNotBackReference(0, false, &done); // Performs a system-stack push.
m.Bind(&done);
m.PushRegister(large_number, RegExpMacroAssembler::kNoStackLimitCheck);
m.PopRegister(1);
@@ -1388,7 +1415,7 @@ TEST(MacroAssembler) {
m.Fail();
m.Bind(&start);
m.PushBacktrack(&fail);
- m.CheckNotAtStart(NULL);
+ m.CheckNotAtStart(0, NULL);
m.LoadCurrentCharacter(0, NULL);
m.CheckNotCharacter('f', NULL);
m.LoadCurrentCharacter(1, NULL);
« no previous file with comments | « src/regexp/x64/regexp-macro-assembler-x64.cc ('k') | test/mjsunit/harmony/regexp-lookbehind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698