summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/RegExp/replace-local-tolength-lastindex.js
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-24 15:54:49 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-24 15:54:49 +0100
commitaae3a117342e8959c074ea9f36cefac772f608d3 (patch)
tree96c19881d204af47f79738f1af911a79d935b94c /js/src/tests/ecma_6/RegExp/replace-local-tolength-lastindex.js
parent893a886ea38853a1a3e97bcf135ea3cb616cd69a (diff)
downloadUXP-aae3a117342e8959c074ea9f36cefac772f608d3.tar
UXP-aae3a117342e8959c074ea9f36cefac772f608d3.tar.gz
UXP-aae3a117342e8959c074ea9f36cefac772f608d3.tar.lz
UXP-aae3a117342e8959c074ea9f36cefac772f608d3.tar.xz
UXP-aae3a117342e8959c074ea9f36cefac772f608d3.zip
Bug 1343375: Update RegExp.prototype.replace and .match to call ToLength(lastIndex) for non-global RegExp and handle recompilations
[Depends on] Bug 1317397: Implement RegExp.lastIndex changes from ES2017
Diffstat (limited to 'js/src/tests/ecma_6/RegExp/replace-local-tolength-lastindex.js')
-rw-r--r--js/src/tests/ecma_6/RegExp/replace-local-tolength-lastindex.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/RegExp/replace-local-tolength-lastindex.js b/js/src/tests/ecma_6/RegExp/replace-local-tolength-lastindex.js
new file mode 100644
index 000000000..7ba840e00
--- /dev/null
+++ b/js/src/tests/ecma_6/RegExp/replace-local-tolength-lastindex.js
@@ -0,0 +1,22 @@
+// RegExp.prototype[@@replace] always executes ToLength(regExp.lastIndex) for
+// non-global RegExps.
+
+for (var flag of ["", "g", "y", "gy"]) {
+ var regExp = new RegExp("a", flag);
+
+ var called = false;
+ regExp.lastIndex = {
+ valueOf() {
+ assertEq(called, false);
+ called = true;
+ return 0;
+ }
+ };
+
+ assertEq(called, false);
+ regExp[Symbol.replace]("");
+ assertEq(called, !flag.includes("g"));
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);