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

Unified Diff: test/mjsunit/string-replace.js

Issue 1418703003: RegExp: remove last match info override. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix 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
« src/runtime/runtime-regexp.cc ('K') | « test/mjsunit/regexp-static.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/string-replace.js
diff --git a/test/mjsunit/string-replace.js b/test/mjsunit/string-replace.js
index de921155759cc5fd3477113727a8a44c393f1ab7..e8392ae2bf0b25bd44e028e47e570dd523317fd8 100644
--- a/test/mjsunit/string-replace.js
+++ b/test/mjsunit/string-replace.js
@@ -163,6 +163,30 @@ replaceTest("0a1b2cx", short, /(x)(?=(.))/g, function r(m, c1, c2, i, s) {
assertEquals(3, ctr, "replace(/x/g,func) num-match");
+replaceTest("ABCD", "abcd", /(.)/g, function r(m, c1, i, s) {
+ assertEquals("d", RegExp.lastMatch);
+ assertEquals("d", RegExp.$1);
+ assertEquals("abc", RegExp.leftContext);
+ return m.toUpperCase();
+});
+
+
+var long = "";
+while (long.length < 0x2000) {
+ long += String.fromCharCode(65 + Math.random() * 26);
+}
+
+for (var i = 0; i < 3; i++) {
+ replaceTest(long.toLowerCase(), long, /(..)/g, function r(m, c1, i, s) {
+ var expected = long.substring(0x1ffe, 0x2000);
+ assertEquals(expected, RegExp.lastMatch);
+ assertEquals(expected, RegExp.$1);
+ assertEquals(long.substring(0, 0x1ffe), RegExp.leftContext);
+ return m.toLowerCase();
+ });
+}
+
+
// Test special cases of replacement parts longer than 1<<11.
var longstring = "xyzzy";
longstring = longstring + longstring;
@@ -194,20 +218,6 @@ replaceTest("aundefinedbundefinedcundefined",
// Test nested calls to replace, including that it sets RegExp.$& correctly.
-function replacer(m,i,s) {
- assertEquals(m,RegExp['$&']);
- return "[" + RegExp['$&'] + "-"
- + m.replace(/./g,"$&$&") + "-"
- + m.replace(/./g,function() { return RegExp['$&']; })
- + "-" + RegExp['$&'] + "]";
-}
-
-replaceTest("[ab-aabb-ab-b][az-aazz-az-z]",
- "abaz", /a./g, replacer);
-
-replaceTest("[ab-aabb-ab-b][az-aazz-az-z]",
- "abaz", /a(.)/g, replacer);
-
var str = 'She sells seashells by the seashore.';
var re = /sh/g;
assertEquals('She sells sea$schells by the sea$schore.',
« src/runtime/runtime-regexp.cc ('K') | « test/mjsunit/regexp-static.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698