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

Unified Diff: test/mjsunit/regress/regress-2437.js

Issue 2685183003: [regexp] Sticky handling in fast slow path (Closed)
Patch Set: Revert "Remove custom ToUint32" Created 3 years, 10 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/mjsunit/regress/regress-2437.js
diff --git a/test/mjsunit/regress/regress-2437.js b/test/mjsunit/regress/regress-2437.js
index 66f0abfef582503751c6ad0164de26fc295aa8a9..d11307948c411018b76ac847e0a3e4bc2cb10100 100644
--- a/test/mjsunit/regress/regress-2437.js
+++ b/test/mjsunit/regress/regress-2437.js
@@ -55,31 +55,31 @@ assertEquals(1, r.lastIndex);
r = /a/;
r.lastIndex = 1;
"zzzz".replace(r, "");
-assertEquals(0, r.lastIndex);
+assertEquals(1, r.lastIndex);
// Test String.prototype.replace with non-atomic regexp and empty string.
r = /\d/;
r.lastIndex = 1;
"zzzz".replace(r, "");
-assertEquals(0, r.lastIndex);
+assertEquals(1, r.lastIndex);
// Test String.prototype.replace with atomic regexp and non-empty string.
r = /a/;
r.lastIndex = 1;
"zzzz".replace(r, "a");
-assertEquals(0, r.lastIndex);
+assertEquals(1, r.lastIndex);
// Test String.prototype.replace with non-atomic regexp and non-empty string.
r = /\d/;
r.lastIndex = 1;
"zzzz".replace(r, "a");
-assertEquals(0, r.lastIndex);
+assertEquals(1, r.lastIndex);
// Test String.prototype.replace with replacement function
r = /a/;
r.lastIndex = 1;
"zzzz".replace(r, function() { return ""; });
-assertEquals(0, r.lastIndex);
+assertEquals(1, r.lastIndex);
// Regexp functions that returns multiple results:
// A global regexp always resets lastIndex regardless of whether it matches.
@@ -100,7 +100,7 @@ r.lastIndex = -1;
"01234567".match(r);
assertEquals(0, r.lastIndex);
-// A non-global regexp resets lastIndex iff it does not match.
+// A non-global regexp resets lastIndex iff it is sticky.
r = /a/;
r.lastIndex = -1;
"0123abcd".replace(r, "x");
@@ -108,7 +108,7 @@ assertEquals(-1, r.lastIndex);
r.lastIndex = -1;
"01234567".replace(r, "x");
-assertEquals(0, r.lastIndex);
+assertEquals(-1, r.lastIndex);
r.lastIndex = -1;
"0123abcd".match(r);
@@ -118,6 +118,16 @@ r.lastIndex = -1;
"01234567".match(r);
assertEquals(-1, r.lastIndex);
+r = /a/y;
+r.lastIndex = -1;
+"0123abcd".replace(r, "x");
+assertEquals(0, r.lastIndex);
+
+r.lastIndex = -1;
+"01234567".replace(r, "x");
+assertEquals(0, r.lastIndex);
+
+
// Also test RegExp.prototype.exec and RegExp.prototype.test
r = /a/g;
r.lastIndex = 1;

Powered by Google App Engine
This is Rietveld 408576698