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.', |