Fix sticky flag handling in @@replace (#4005)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
This commit is contained in:
@@ -680,9 +680,45 @@ Object.defineProperty(abruptStickyRegexp, 'sticky', {
|
||||
}
|
||||
});
|
||||
|
||||
assert(abruptStickyRegexp[Symbol.replace]() === "undefinedndefined");
|
||||
|
||||
var r = /./;
|
||||
r.lastIndex = {
|
||||
valueOf: function() {
|
||||
throw "abrupt lastIndex"
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
abruptStickyRegexp[Symbol.replace]();
|
||||
r[Symbol.replace]("a", "b");
|
||||
assert(false);
|
||||
} catch (e) {
|
||||
assert(e === "abrupt sticky");
|
||||
assert(e === "abrupt lastIndex");
|
||||
}
|
||||
|
||||
var r = /a/y;
|
||||
r.lastIndex = 3;
|
||||
assert (r[Symbol.replace]("aaaaa", "b") === "aaaba");
|
||||
assert (r.lastIndex === 4);
|
||||
|
||||
assert (r[Symbol.replace]("ccccc", "b") === "ccccc");
|
||||
assert (r.lastIndex === 0);
|
||||
|
||||
var r = /a/yg;
|
||||
r.lastIndex = 3;
|
||||
assert (r[Symbol.replace]("aaaaa", "b") === "bbbbb");
|
||||
assert (r.lastIndex === 0);
|
||||
|
||||
var replaceCalled = false;
|
||||
var r = /a/
|
||||
r.lastIndex = 2;
|
||||
|
||||
assert(r[Symbol.replace]("aaaa", function(match, index) {
|
||||
replaceCalled = true;
|
||||
assert (match === "a");
|
||||
assert (index === 0);
|
||||
return "b";
|
||||
}) === "baaa");
|
||||
|
||||
assert (replaceCalled);
|
||||
assert (r.lastIndex === 2)
|
||||
|
||||
@@ -132,3 +132,17 @@ try {
|
||||
} catch (e) {
|
||||
assert (e === "abrupt replacer toString");
|
||||
}
|
||||
|
||||
var r = /./;
|
||||
r.lastIndex = {
|
||||
valueOf: function() {
|
||||
throw "abrupt lastIndex"
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
"a".replace(r, "b");
|
||||
assert(false);
|
||||
} catch (e) {
|
||||
assert(e === "abrupt lastIndex");
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@
|
||||
<test id="built-ins/Reflect/enumerate/name.js"><reason></reason></test>
|
||||
<test id="built-ins/Reflect/enumerate/return-abrupt-from-result.js"><reason></reason></test>
|
||||
<test id="built-ins/Reflect/enumerate/return-iterator.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/exec/get-sticky-coerce.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/exec/get-sticky-err.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/exec/get-sticky-coerce.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/exec/get-sticky-err.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-coerce-global.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-coerce-lastindex-err.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-coerce-sticky.js"><reason></reason></test>
|
||||
@@ -92,18 +92,12 @@
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex-err.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/coerce-global.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/coerce-sticky.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/get-sticky-err.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.replace/coerce-global.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.replace/coerce-unicode.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.replace/get-sticky-coerce.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.replace/y-fail-global-return.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.replace/y-fail-lastindex.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.replace/y-fail-lastindex-no-write.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.replace/y-fail-return.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.replace/y-set-lastindex.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.search/get-sticky-coerce.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.search/get-sticky-err.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/coerce-sticky.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/get-sticky-err.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.replace/get-sticky-coerce.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.replace/get-sticky-err.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.search/get-sticky-coerce.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.search/get-sticky-err.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.split/coerce-limit.js"><reason>Test is outdated: ES11, 21.2.5.13 13</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/test/get-sticky-err.js"><reason></reason></test>
|
||||
<test id="built-ins/String/prototype/normalize/form-is-not-valid-throws.js"><reason></reason></test>
|
||||
|
||||
Reference in New Issue
Block a user