diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-03-27 13:22:30 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-03-27 13:22:30 +0200 |
commit | 8d5ec757ece850fb7ad5c712868f305636e41177 (patch) | |
tree | 92acdb7783ab29bdfa2837ad54afa491c2c42867 /js/src/tests/ecma_6/RegExp/replace-local-tolength-lastindex.js | |
parent | e19749682050ff716fc9ff3bbc05ee3911570670 (diff) | |
parent | 5fd5b2ac2f396eb1d8707a691aa26ad159ad25e3 (diff) | |
download | UXP-8d5ec757ece850fb7ad5c712868f305636e41177.tar UXP-8d5ec757ece850fb7ad5c712868f305636e41177.tar.gz UXP-8d5ec757ece850fb7ad5c712868f305636e41177.tar.lz UXP-8d5ec757ece850fb7ad5c712868f305636e41177.tar.xz UXP-8d5ec757ece850fb7ad5c712868f305636e41177.zip |
Merge remote-tracking branch 'janek/js_regexp_lastindex_1'
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.js | 22 |
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); |