Update lastIndex handling in RegExpBuiltinExec (#4010)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]
This commit is contained in:
1 parent
69f6bc6566
commit
1eef69f24d
5 files changed
+165
-97
No files matched your search
@@ -12,11 +12,56 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var t = new RegExp ("abc","g");
|
||||
t.lastIndex = -12;
|
||||
var t = /abc/g;
|
||||
t.lastIndex = -12.5;
|
||||
result = t.exec("abc abc");
|
||||
assert(result[0] === "abc");
|
||||
assert(result.index === 0);
|
||||
assert(t.lastIndex === 3);
|
||||
|
||||
assert(RegExp.prototype.lastIndex === undefined)
|
||||
|
||||
var r = /./y
|
||||
r.lastIndex = -1;
|
||||
assert (JSON.stringify(r.exec("abca")) === '["a"]');
|
||||
assert (r.lastIndex === 1);
|
||||
assert (JSON.stringify(r.exec("abca")) === '["b"]');
|
||||
assert (r.lastIndex === 2);
|
||||
|
||||
r.lastIndex = 5;
|
||||
assert (JSON.stringify(r.exec("abca")) === 'null');
|
||||
assert (r.lastIndex === 0);
|
||||
|
||||
var r = /a/y
|
||||
assert (JSON.stringify(r.exec("abca")) === '["a"]');
|
||||
assert (r.lastIndex === 1);
|
||||
assert (JSON.stringify(r.exec("abca")) === 'null');
|
||||
assert (r.lastIndex === 0);
|
||||
|
||||
var r = /./g
|
||||
r.lastIndex = -1;
|
||||
assert (JSON.stringify(r.exec("abca")) === '["a"]');
|
||||
assert (r.lastIndex === 1);
|
||||
assert (JSON.stringify(r.exec("abca")) === '["b"]');
|
||||
assert (r.lastIndex === 2);
|
||||
|
||||
r.lastIndex = 5;
|
||||
assert (JSON.stringify(r.exec("abca")) === 'null');
|
||||
assert (r.lastIndex === 0);
|
||||
|
||||
var r = /a/g
|
||||
assert (JSON.stringify(r.exec("abca")) === '["a"]');
|
||||
assert (r.lastIndex === 1);
|
||||
assert (JSON.stringify(r.exec("abca")) === '["a"]');
|
||||
assert (r.lastIndex === 4);
|
||||
assert (JSON.stringify(r.exec("abca")) === 'null');
|
||||
assert (r.lastIndex === 0);
|
||||
|
||||
var r = /./uim
|
||||
r.lastIndex = 2;
|
||||
assert (JSON.stringify(r.exec("abcd")) === '["a"]');
|
||||
assert (r.lastIndex === 2);
|
||||
|
||||
r.lastIndex = "lastIndex";
|
||||
assert (JSON.stringify(r.exec("abcd")) === '["a"]');
|
||||
assert (r.lastIndex === "lastIndex");
|
||||
@@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var t = new RegExp ("abc","g");
|
||||
t.lastIndex = -12;
|
||||
var t = /abc/g;
|
||||
t.lastIndex = -12.5;
|
||||
result = t.exec("abc abc");
|
||||
assert(!result);
|
||||
assert(t.lastIndex === 0);
|
||||
@@ -101,3 +101,17 @@ assert (re2.ignoreCase === re1.ignoreCase);
|
||||
assert (re2.multiline === re1.multiline);
|
||||
assert (re2.source === re1.source);
|
||||
assert (re2.lastIndex === 0);
|
||||
|
||||
var r = /./
|
||||
r.lastIndex = {
|
||||
valueOf: function() {
|
||||
throw "abrupt lastIndex"
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
r.exec("a");
|
||||
assert(false);
|
||||
} catch (e) {
|
||||
assert (e === "abrupt lastIndex");
|
||||
}
|
||||
@@ -82,16 +82,15 @@
|
||||
<test id="built-ins/Reflect/enumerate/return-iterator.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>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex-err.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-get-global-err.js"><reason></reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-get-sticky-err.js"><reason></reason></test>
|
||||
<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/builtin-coerce-global.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-coerce-sticky.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex-err.js"><reason>lastIndex no longer needs to be updated if not sticky or global</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex.js"><reason>lastIndex no longer needs to be updated if not sticky or global</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-get-global-err.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-get-sticky-err.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex-err.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/RegExp/prototype/Symbol.match/coerce-global.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</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>
|
||||
@@ -99,7 +98,7 @@
|
||||
<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/RegExp/prototype/test/get-sticky-err.js"><reason>RegExpBuiltinExec no longer uses accessors to get flags</reason></test>
|
||||
<test id="built-ins/String/prototype/normalize/form-is-not-valid-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/String/prototype/normalize/length.js"><reason></reason></test>
|
||||
<test id="built-ins/String/prototype/normalize/name.js"><reason></reason></test>
|
||||
|
||||
Reference in new issue
Block a user