mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 15:34:29 +02:00
Update RegExp tests (#614)
The RegExpBuiltinExec internal operation was modified in March of 2016 [1]: instead of referencing the `global` and `sticky` properties of the "this" value, the algorithm now infers those values from the object's [[OriginalFlags]] internal slot. This change invalidated a number of tests. In cases where the change resulted in an observable behavior, update the tests to assert the latest specification text. In cases where the change removed a previously-observable behavior, remove the files completely. Specification text change set: > 1. Assert: Type(_S_) is String. > 1. Let _length_ be the number of code units in _S_. > 1. Let _lastIndex_ be ? ToLength(? Get(_R_, `"lastIndex"`)). > - 1. Let _global_ be ToBoolean(? Get(_R_, `"global"`)). > - 1. Let _sticky_ be ToBoolean(? Get(_R_, `"sticky"`)). > + 1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot. > + 1. If _flags_ contains `"g"`, let _global_ be *true*, else let _global_ be *false*. > + 1. If _flags_ contains `"y"`, let _sticky_ be *true*, else let _sticky_ be *false*. > 1. If _global_ is *false* and _sticky_ is *false*, let _lastIndex_ be 0. > 1. Let _matcher_ be the value of _R_'s [[RegExpMatcher]] internal slot. > - 1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot. > 1. If _flags_ contains `"u"`, let _fullUnicode_ be *true*, else let _fullUnicode_ be *false*. > 1. Let _matchSucceeded_ be *false*. > 1. Repeat, while _matchSucceeded_ is *false* [1] https://github.com/tc39/ecma262/pull/494
This commit is contained in:
parent
f7a61edc6f
commit
d9d3f7cf4f
@ -1,97 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Type coercion of `global` property value
|
|
||||||
es6id: 21.2.5.6
|
|
||||||
info: >
|
|
||||||
[...]
|
|
||||||
5. Let global be ToBoolean(Get(rx, "global")).
|
|
||||||
6. ReturnIfAbrupt(global).
|
|
||||||
7. If global is false, then
|
|
||||||
a. Return RegExpExec(rx, S).
|
|
||||||
|
|
||||||
21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
7. Return RegExpBuiltinExec(R, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
6. Let global be ToBoolean(Get(R, "global")).
|
|
||||||
features: [Symbol.match]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /./;
|
|
||||||
var val, result;
|
|
||||||
Object.defineProperty(r, 'global', {
|
|
||||||
get: function() {
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
val = false;
|
|
||||||
result = r[Symbol.match]('ab');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
assert.sameValue(result[0], 'a');
|
|
||||||
|
|
||||||
val = '';
|
|
||||||
result = r[Symbol.match]('ab');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
assert.sameValue(result[0], 'a');
|
|
||||||
|
|
||||||
val = 0;
|
|
||||||
result = r[Symbol.match]('ab');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
assert.sameValue(result[0], 'a');
|
|
||||||
|
|
||||||
val = null;
|
|
||||||
result = r[Symbol.match]('ab');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
assert.sameValue(result[0], 'a');
|
|
||||||
|
|
||||||
val = undefined;
|
|
||||||
result = r[Symbol.match]('ab');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
assert.sameValue(result[0], 'a');
|
|
||||||
|
|
||||||
val = true;
|
|
||||||
result = r[Symbol.match]('ab');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 2);
|
|
||||||
assert.sameValue(result[0], 'a');
|
|
||||||
assert.sameValue(result[1], 'b');
|
|
||||||
|
|
||||||
val = 'truthy';
|
|
||||||
result = r[Symbol.match]('ab');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 2);
|
|
||||||
assert.sameValue(result[0], 'a');
|
|
||||||
assert.sameValue(result[1], 'b');
|
|
||||||
|
|
||||||
val = 86;
|
|
||||||
result = r[Symbol.match]('ab');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 2);
|
|
||||||
assert.sameValue(result[0], 'a');
|
|
||||||
assert.sameValue(result[1], 'b');
|
|
||||||
|
|
||||||
val = [];
|
|
||||||
result = r[Symbol.match]('ab');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 2);
|
|
||||||
assert.sameValue(result[0], 'a');
|
|
||||||
assert.sameValue(result[1], 'b');
|
|
||||||
|
|
||||||
val = Symbol.match;
|
|
||||||
result = r[Symbol.match]('ab');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 2);
|
|
||||||
assert.sameValue(result[0], 'a');
|
|
||||||
assert.sameValue(result[1], 'b');
|
|
@ -1,79 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Type coercion of `sticky` property value
|
|
||||||
es6id: 21.2.5.6
|
|
||||||
info: >
|
|
||||||
[...]
|
|
||||||
5. Let global be ToBoolean(Get(rx, "global")).
|
|
||||||
6. ReturnIfAbrupt(global).
|
|
||||||
7. If global is false, then
|
|
||||||
a. Return RegExpExec(rx, S).
|
|
||||||
|
|
||||||
21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
7. Return RegExpBuiltinExec(R, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
[...]
|
|
||||||
18. If global is true or sticky is true,
|
|
||||||
a. Let setStatus be Set(R, "lastIndex", e, true).
|
|
||||||
features: [Symbol.match]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /./;
|
|
||||||
var val;
|
|
||||||
Object.defineProperty(r, 'sticky', {
|
|
||||||
get: function() {
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
val = false;
|
|
||||||
r[Symbol.match]('a');
|
|
||||||
assert.sameValue(r.lastIndex, 0, 'literal false');
|
|
||||||
|
|
||||||
val = '';
|
|
||||||
r[Symbol.match]('a');
|
|
||||||
assert.sameValue(r.lastIndex, 0, 'empty string');
|
|
||||||
|
|
||||||
val = 0;
|
|
||||||
r[Symbol.match]('a');
|
|
||||||
assert.sameValue(r.lastIndex, 0, 'zero');
|
|
||||||
|
|
||||||
val = null;
|
|
||||||
r[Symbol.match]('a');
|
|
||||||
assert.sameValue(r.lastIndex, 0, 'null');
|
|
||||||
|
|
||||||
val = undefined;
|
|
||||||
r[Symbol.match]('a');
|
|
||||||
assert.sameValue(r.lastIndex, 0, 'undefined');
|
|
||||||
|
|
||||||
val = true;
|
|
||||||
r[Symbol.match]('a');
|
|
||||||
assert.sameValue(r.lastIndex, 1, 'literal true');
|
|
||||||
|
|
||||||
r.lastIndex = 0;
|
|
||||||
val = 'truthy';
|
|
||||||
r[Symbol.match]('a');
|
|
||||||
assert.sameValue(r.lastIndex, 1, 'non-empty string');
|
|
||||||
|
|
||||||
r.lastIndex = 0;
|
|
||||||
val = 86;
|
|
||||||
r[Symbol.match]('a');
|
|
||||||
assert.sameValue(r.lastIndex, 1, 'nonzero number');
|
|
||||||
|
|
||||||
r.lastIndex = 0;
|
|
||||||
val = [];
|
|
||||||
r[Symbol.match]('a');
|
|
||||||
assert.sameValue(r.lastIndex, 1, 'array');
|
|
||||||
|
|
||||||
r.lastIndex = 0;
|
|
||||||
val = Symbol.match;
|
|
||||||
r[Symbol.match]('a');
|
|
||||||
assert.sameValue(r.lastIndex, 1, 'symbol');
|
|
@ -1,41 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Behavior when error thrown by accessing the `global` property
|
|
||||||
es6id: 21.2.5.6
|
|
||||||
info: >
|
|
||||||
[...]
|
|
||||||
5. Let global be ToBoolean(Get(rx, "global")).
|
|
||||||
6. ReturnIfAbrupt(global).
|
|
||||||
7. If global is false, then
|
|
||||||
a. Return RegExpExec(rx, S).
|
|
||||||
|
|
||||||
21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
7. Return RegExpBuiltinExec(R, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
6. Let global be ToBoolean(Get(R, "global")).
|
|
||||||
7. ReturnIfAbrupt(global).
|
|
||||||
features: [Symbol.match]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /./;
|
|
||||||
var callCount = 0;
|
|
||||||
Object.defineProperty(r, 'global', {
|
|
||||||
get: function() {
|
|
||||||
callCount += 1;
|
|
||||||
|
|
||||||
if (callCount > 1) {
|
|
||||||
throw new Test262Error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
|
||||||
r[Symbol.match]('');
|
|
||||||
});
|
|
@ -1,37 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Behavior when error thrown by accessing the `sticky` property
|
|
||||||
es6id: 21.2.5.6
|
|
||||||
info: >
|
|
||||||
[...]
|
|
||||||
5. Let global be ToBoolean(Get(rx, "global")).
|
|
||||||
6. ReturnIfAbrupt(global).
|
|
||||||
7. If global is false, then
|
|
||||||
a. Return RegExpExec(rx, S).
|
|
||||||
|
|
||||||
21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
7. Return RegExpBuiltinExec(R, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
9. ReturnIfAbrupt(sticky).
|
|
||||||
features: [Symbol.match]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /./;
|
|
||||||
var shouldThrow = false;
|
|
||||||
Object.defineProperty(r, 'sticky', {
|
|
||||||
get: function() {
|
|
||||||
throw new Test262Error();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
|
||||||
r[Symbol.match]('');
|
|
||||||
});
|
|
@ -27,14 +27,23 @@ info: >
|
|||||||
features: [Symbol.match]
|
features: [Symbol.match]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var r = /b/;
|
var r = /b/g;
|
||||||
var callCount = 0;
|
var callCount = 0;
|
||||||
|
|
||||||
Object.defineProperty(r, 'lastIndex', { writable: false });
|
// Because this test speicifically concerns the behavior when setting
|
||||||
Object.defineProperty(r, 'global', {
|
// "lastIndex" following a match, care must be taken to avoid triggering a
|
||||||
|
// similar error when `lastIndex` is initially set to `0` earlier in the
|
||||||
|
// algorithm.
|
||||||
|
//
|
||||||
|
// Because the `lastIndex` property is non-configurable, this cannot be
|
||||||
|
// accomplished with a simple "set" accessor function.
|
||||||
|
//
|
||||||
|
// Defer disabling modification of `lastIndex` until after the "this" value's
|
||||||
|
// `exec` property has been accessed, ensuring that the resultant abrupt
|
||||||
|
// completion originates from the second property modification.
|
||||||
|
Object.defineProperty(r, 'exec', {
|
||||||
get: function() {
|
get: function() {
|
||||||
callCount += 1;
|
Object.defineProperty(r, 'lastIndex', { writable: false });
|
||||||
return callCount > 1;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Setting `lastIndex` after a "global" match success
|
description: Setting `lastIndex` after a "global" match success
|
||||||
es6id: 21.2.5.6
|
esid: sec-regexp.prototype-@@match
|
||||||
info: >
|
info: >
|
||||||
[...]
|
[...]
|
||||||
5. Let global be ToBoolean(Get(rx, "global")).
|
5. Let global be ToBoolean(Get(rx, "global")).
|
||||||
@ -18,6 +18,9 @@ info: >
|
|||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
||||||
|
|
||||||
|
[...]
|
||||||
|
5. Let flags be the value of R's [[OriginalFlags]] internal slot.
|
||||||
|
6. If flags contains "g", let global be true, else let global be false.
|
||||||
[...]
|
[...]
|
||||||
16. Let e be r's endIndex value.
|
16. Let e be r's endIndex value.
|
||||||
[...]
|
[...]
|
||||||
@ -26,15 +29,10 @@ info: >
|
|||||||
features: [Symbol.match]
|
features: [Symbol.match]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var r = /b/;
|
// The conflicting values for the "global" flag are necessary to observe the
|
||||||
var callCount = 0;
|
// final modification of `lastIndex` in RegExpBuiltinExec
|
||||||
|
var r = /b/g;
|
||||||
Object.defineProperty(r, 'global', {
|
Object.defineProperty(r, 'global', { value: false });
|
||||||
get: function() {
|
|
||||||
callCount += 1;
|
|
||||||
return callCount > 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
r[Symbol.match]('abc');
|
r[Symbol.match]('abc');
|
||||||
|
|
||||||
|
@ -3,66 +3,83 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Boolean coercion of `global` property
|
description: Boolean coercion of `global` property
|
||||||
es6id: 21.2.5.6
|
esid: sec-regexp.prototype-@@match
|
||||||
info: >
|
info: >
|
||||||
21.2.5.6 RegExp.prototype [ @@match ] ( string )
|
21.2.5.6 RegExp.prototype [ @@match ] ( string )
|
||||||
|
|
||||||
[...]
|
[...]
|
||||||
5. Let global be ToBoolean(Get(rx, "global")).
|
4. Let global be ToBoolean(? Get(rx, "global")).
|
||||||
|
5. If global is false, then
|
||||||
|
a. Return ? RegExpExec(rx, S).
|
||||||
|
6. Else global is true,
|
||||||
|
a. Let fullUnicode be ToBoolean(? Get(rx, "unicode")).
|
||||||
[...]
|
[...]
|
||||||
features: [Symbol.match]
|
features: [Symbol.match]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var r = /a/;
|
var exec = function() {
|
||||||
var result;
|
execCount += 1;
|
||||||
|
if (execCount === 1) {
|
||||||
|
return [''];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
var r, result, execCount;
|
||||||
|
|
||||||
|
r = /a/g;
|
||||||
|
r.exec = exec;
|
||||||
Object.defineProperty(r, 'global', { writable: true });
|
Object.defineProperty(r, 'global', { writable: true });
|
||||||
|
|
||||||
|
execCount = 0;
|
||||||
r.global = undefined;
|
r.global = undefined;
|
||||||
result = r[Symbol.match]('aa');
|
r[Symbol.match]('aa');
|
||||||
assert.notSameValue(result, null);
|
assert.sameValue(execCount, 1, 'value: undefined');
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
|
|
||||||
|
execCount = 0;
|
||||||
r.global = null;
|
r.global = null;
|
||||||
result = r[Symbol.match]('aa');
|
r[Symbol.match]('aa');
|
||||||
assert.notSameValue(result, null);
|
assert.sameValue(execCount, 1, 'value: null');
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
|
execCount = 0;
|
||||||
|
r.global = false;
|
||||||
|
r[Symbol.match]('aa');
|
||||||
|
assert.sameValue(execCount, 1, 'value: false');
|
||||||
|
|
||||||
|
execCount = 0;
|
||||||
|
r.global = NaN;
|
||||||
|
r[Symbol.match]('aa');
|
||||||
|
assert.sameValue(execCount, 1, 'value: NaN');
|
||||||
|
|
||||||
|
execCount = 0;
|
||||||
|
r.global = 0;
|
||||||
|
r[Symbol.match]('aa');
|
||||||
|
assert.sameValue(execCount, 1, 'value: 0');
|
||||||
|
|
||||||
|
execCount = 0;
|
||||||
|
r.global = '';
|
||||||
|
r[Symbol.match]('aa');
|
||||||
|
assert.sameValue(execCount, 1, 'value: ""');
|
||||||
|
|
||||||
|
r = /a/;
|
||||||
|
r.exec = exec;
|
||||||
|
Object.defineProperty(r, 'global', { writable: true });
|
||||||
|
|
||||||
r.global = true;
|
r.global = true;
|
||||||
result = r[Symbol.match]('aa');
|
execCount = 0;
|
||||||
assert.notSameValue(result, null);
|
r[Symbol.match]('aa');
|
||||||
assert.notSameValue(result.length, 1);
|
assert.sameValue(execCount, 2, 'value: true');
|
||||||
|
|
||||||
r.global = false;
|
|
||||||
result = r[Symbol.match]('aa');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
|
|
||||||
r.global = NaN;
|
|
||||||
result = r[Symbol.match]('aa');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
|
|
||||||
r.global = 0;
|
|
||||||
result = r[Symbol.match]('aa');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
|
|
||||||
r.global = '';
|
|
||||||
result = r[Symbol.match]('aa');
|
|
||||||
assert.notSameValue(result, null);
|
|
||||||
assert.sameValue(result.length, 1);
|
|
||||||
|
|
||||||
r.global = 86;
|
r.global = 86;
|
||||||
result = r[Symbol.match]('aa');
|
execCount = 0;
|
||||||
assert.notSameValue(result, null);
|
r[Symbol.match]('aa');
|
||||||
assert.sameValue(result.length, 2);
|
assert.sameValue(execCount, 2, 'value: 86');
|
||||||
|
|
||||||
r.global = Symbol.match;
|
r.global = Symbol.match;
|
||||||
result = r[Symbol.match]('aa');
|
execCount = 0;
|
||||||
assert.notSameValue(result, null);
|
r[Symbol.match]('aa');
|
||||||
assert.sameValue(result.length, 2);
|
assert.sameValue(execCount, 2, 'value: Symbol.match');
|
||||||
|
|
||||||
r.global = {};
|
r.global = {};
|
||||||
result = r[Symbol.match]('aa');
|
execCount = 0;
|
||||||
assert.notSameValue(result, null);
|
r[Symbol.match]('aa');
|
||||||
assert.sameValue(result.length, 2);
|
assert.sameValue(execCount, 2, 'value: {}');
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Boolean coercion of `sticky` property
|
|
||||||
es6id: 21.2.5.6
|
|
||||||
info: >
|
|
||||||
21.2.5.6 RegExp.prototype [ @@match ] ( string )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
5. Let global be ToBoolean(Get(rx, "global")).
|
|
||||||
6. ReturnIfAbrupt(global).
|
|
||||||
7. If global is false, then
|
|
||||||
a. Return RegExpExec(rx, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
features: [Symbol.match]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /a/;
|
|
||||||
Object.defineProperty(r, 'sticky', { writable: true });
|
|
||||||
|
|
||||||
r.sticky = undefined;
|
|
||||||
assert.notSameValue(r[Symbol.match]('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = null;
|
|
||||||
assert.notSameValue(r[Symbol.match]('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = true;
|
|
||||||
assert.sameValue(r[Symbol.match]('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = false;
|
|
||||||
assert.notSameValue(r[Symbol.match]('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = NaN;
|
|
||||||
assert.notSameValue(r[Symbol.match]('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = 0;
|
|
||||||
assert.notSameValue(r[Symbol.match]('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = '';
|
|
||||||
assert.notSameValue(r[Symbol.match]('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = 86;
|
|
||||||
assert.sameValue(r[Symbol.match]('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = Symbol.match;
|
|
||||||
assert.sameValue(r[Symbol.match]('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = {};
|
|
||||||
assert.sameValue(r[Symbol.match]('ba'), null);
|
|
@ -1,33 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Behavior if error is thrown when accessing `sticky` property
|
|
||||||
es6id: 21.2.5.6
|
|
||||||
info: >
|
|
||||||
21.2.5.6 RegExp.prototype [ @@match ] ( string )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
5. Let global be ToBoolean(Get(rx, "global")).
|
|
||||||
6. ReturnIfAbrupt(global).
|
|
||||||
7. If global is false, then
|
|
||||||
a. Return RegExpExec(rx, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
9. ReturnIfAbrupt(sticky).
|
|
||||||
features: [Symbol.match]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /./;
|
|
||||||
Object.defineProperty(r, 'sticky', {
|
|
||||||
get: function() {
|
|
||||||
throw new Test262Error();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
|
||||||
r[Symbol.match]();
|
|
||||||
});
|
|
@ -13,35 +13,61 @@ info: >
|
|||||||
features: [Symbol.replace]
|
features: [Symbol.replace]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var r = /a/;
|
Array.print = print;
|
||||||
|
var r = /a/g;
|
||||||
Object.defineProperty(r, 'global', { writable: true });
|
Object.defineProperty(r, 'global', { writable: true });
|
||||||
|
|
||||||
|
r.lastIndex = 0;
|
||||||
r.global = undefined;
|
r.global = undefined;
|
||||||
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba');
|
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba', 'value: undefined');
|
||||||
|
|
||||||
|
r.lastIndex = 0;
|
||||||
r.global = null;
|
r.global = null;
|
||||||
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba');
|
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba', 'value: null');
|
||||||
|
|
||||||
|
r.lastIndex = 0;
|
||||||
r.global = false;
|
r.global = false;
|
||||||
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba');
|
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba', 'value: false');
|
||||||
|
|
||||||
|
r.lastIndex = 0;
|
||||||
r.global = NaN;
|
r.global = NaN;
|
||||||
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba');
|
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba', 'value: NaN');
|
||||||
|
|
||||||
|
r.lastIndex = 0;
|
||||||
r.global = 0;
|
r.global = 0;
|
||||||
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba');
|
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba', 'value: global');
|
||||||
|
|
||||||
|
r.lastIndex = 0;
|
||||||
r.global = '';
|
r.global = '';
|
||||||
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba');
|
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'ba', 'value: ""');
|
||||||
|
|
||||||
|
var execCount = 0;
|
||||||
|
r = /a/;
|
||||||
|
Object.defineProperty(r, 'global', { writable: true });
|
||||||
|
r.exec = function() {
|
||||||
|
execCount += 1;
|
||||||
|
if (execCount === 1) {
|
||||||
|
return ['a'];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
execCount = 0;
|
||||||
r.global = true;
|
r.global = true;
|
||||||
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'bb');
|
r[Symbol.replace]('aa', 'b');
|
||||||
|
assert.sameValue(execCount, 2, 'value: true');
|
||||||
|
|
||||||
|
execCount = 0;
|
||||||
r.global = 86;
|
r.global = 86;
|
||||||
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'bb');
|
r[Symbol.replace]('aa', 'b');
|
||||||
|
assert.sameValue(execCount, 2, 'value: 86');
|
||||||
|
|
||||||
|
execCount = 0;
|
||||||
r.global = Symbol.replace;
|
r.global = Symbol.replace;
|
||||||
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'bb');
|
r[Symbol.replace]('aa', 'b');
|
||||||
|
assert.sameValue(execCount, 2, 'value: Symbol.replace');
|
||||||
|
|
||||||
|
execCount = 0;
|
||||||
r.global = {};
|
r.global = {};
|
||||||
assert.sameValue(r[Symbol.replace]('aa', 'b'), 'bb');
|
r[Symbol.replace]('aa', 'b');
|
||||||
|
assert.sameValue(execCount, 2, 'value: {}');
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Boolean coercion of `sticky` property
|
|
||||||
es6id: 21.2.5.8
|
|
||||||
info: >
|
|
||||||
21.2.5.8 RegExp.prototype [ @@replace ] ( string, replaceValue )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
13. Repeat, while done is false
|
|
||||||
a. Let result be RegExpExec(rx, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
9. ReturnIfAbrupt(sticky).
|
|
||||||
features: [Symbol.replace]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /a/;
|
|
||||||
Object.defineProperty(r, 'sticky', { writable: true });
|
|
||||||
|
|
||||||
r.sticky = undefined;
|
|
||||||
assert.sameValue(r[Symbol.replace]('ba', 'x'), 'bx');
|
|
||||||
|
|
||||||
r.sticky = null;
|
|
||||||
assert.sameValue(r[Symbol.replace]('ba', 'x'), 'bx');
|
|
||||||
|
|
||||||
r.sticky = true;
|
|
||||||
assert.sameValue(r[Symbol.replace]('ba', 'x'), 'ba');
|
|
||||||
|
|
||||||
r.sticky = false;
|
|
||||||
assert.sameValue(r[Symbol.replace]('ba', 'x'), 'bx');
|
|
||||||
|
|
||||||
r.sticky = NaN;
|
|
||||||
assert.sameValue(r[Symbol.replace]('ba', 'x'), 'bx');
|
|
||||||
|
|
||||||
r.sticky = 0;
|
|
||||||
assert.sameValue(r[Symbol.replace]('ba', 'x'), 'bx');
|
|
||||||
|
|
||||||
r.sticky = 86;
|
|
||||||
assert.sameValue(r[Symbol.replace]('ba', 'x'), 'ba');
|
|
||||||
|
|
||||||
r.sticky = '';
|
|
||||||
assert.sameValue(r[Symbol.replace]('ba', 'x'), 'bx');
|
|
||||||
|
|
||||||
r.sticky = Symbol();
|
|
||||||
assert.sameValue(r[Symbol.replace]('ba', 'x'), 'ba');
|
|
||||||
|
|
||||||
r.sticky = {};
|
|
||||||
assert.sameValue(r[Symbol.replace]('ba', 'x'), 'ba');
|
|
@ -1,31 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Behavior if error is thrown when accessing `sticky` property
|
|
||||||
es6id: 21.2.5.8
|
|
||||||
info: >
|
|
||||||
21.2.5.8 RegExp.prototype [ @@replace ] ( string, replaceValue )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
13. Repeat, while done is false
|
|
||||||
a. Let result be RegExpExec(rx, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
9. ReturnIfAbrupt(sticky).
|
|
||||||
features: [Symbol.replace]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /./;
|
|
||||||
Object.defineProperty(r, 'sticky', {
|
|
||||||
get: function() {
|
|
||||||
throw new Test262Error();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
|
||||||
r[Symbol.replace]();
|
|
||||||
});
|
|
@ -1,54 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Boolean coercion of `sticky` property
|
|
||||||
es6id: 21.2.5.9
|
|
||||||
info: >
|
|
||||||
21.2.5.9 RegExp.prototype [ @@search ] ( string )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
9. Let result be RegExpExec(rx, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
4. Let lastIndex be ToLength(Get(R,"lastIndex")).
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
[...]
|
|
||||||
features: [Symbol, Symbol.search]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /a/;
|
|
||||||
Object.defineProperty(r, 'sticky', { writable: true });
|
|
||||||
|
|
||||||
r.sticky = undefined;
|
|
||||||
assert.sameValue(r[Symbol.search]('ba'), 1);
|
|
||||||
|
|
||||||
r.sticky = null;
|
|
||||||
assert.sameValue(r[Symbol.search]('ba'), 1);
|
|
||||||
|
|
||||||
r.sticky = true;
|
|
||||||
assert.sameValue(r[Symbol.search]('ba'), -1);
|
|
||||||
|
|
||||||
r.sticky = false;
|
|
||||||
assert.sameValue(r[Symbol.search]('ba'), 1);
|
|
||||||
|
|
||||||
r.sticky = NaN;
|
|
||||||
assert.sameValue(r[Symbol.search]('ba'), 1);
|
|
||||||
|
|
||||||
r.sticky = 0;
|
|
||||||
assert.sameValue(r[Symbol.search]('ba'), 1);
|
|
||||||
|
|
||||||
r.sticky = 86;
|
|
||||||
assert.sameValue(r[Symbol.search]('ba'), -1);
|
|
||||||
|
|
||||||
r.sticky = '';
|
|
||||||
assert.sameValue(r[Symbol.search]('ba'), 1);
|
|
||||||
|
|
||||||
r.sticky = Symbol();
|
|
||||||
assert.sameValue(r[Symbol.search]('ba'), -1);
|
|
||||||
|
|
||||||
r.sticky = {};
|
|
||||||
assert.sameValue(r[Symbol.search]('ba'), -1);
|
|
@ -1,30 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Behavior if error is thrown when accessing `sticky` property
|
|
||||||
es6id: 21.2.5.9
|
|
||||||
info: >
|
|
||||||
21.2.5.9 RegExp.prototype [ @@search ] ( string )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
9. Let result be RegExpExec(rx, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
9. ReturnIfAbrupt(sticky).
|
|
||||||
features: [Symbol.search]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /./;
|
|
||||||
Object.defineProperty(r, 'sticky', {
|
|
||||||
get: function() {
|
|
||||||
throw new Test262Error();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
|
||||||
r[Symbol.search]();
|
|
||||||
});
|
|
@ -1,52 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Boolean coercion of `sticky` property
|
|
||||||
es6id: 21.2.5.2
|
|
||||||
info: >
|
|
||||||
21.2.5.2 RegExp.prototype.exec ( string )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
6. Return RegExpBuiltinExec(R, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
[...]
|
|
||||||
features: [Symbol]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /a/;
|
|
||||||
Object.defineProperty(r, 'sticky', { writable: true });
|
|
||||||
|
|
||||||
r.sticky = undefined;
|
|
||||||
assert.notSameValue(r.exec('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = null;
|
|
||||||
assert.notSameValue(r.exec('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = true;
|
|
||||||
assert.sameValue(r.exec('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = false;
|
|
||||||
assert.notSameValue(r.exec('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = NaN;
|
|
||||||
assert.notSameValue(r.exec('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = 0;
|
|
||||||
assert.notSameValue(r.exec('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = 86;
|
|
||||||
assert.sameValue(r.exec('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = '';
|
|
||||||
assert.notSameValue(r.exec('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = Symbol();
|
|
||||||
assert.sameValue(r.exec('ba'), null);
|
|
||||||
|
|
||||||
r.sticky = {};
|
|
||||||
assert.sameValue(r.exec('ba'), null);
|
|
@ -1,29 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Behavior if error is thrown when accessing `sticky` property
|
|
||||||
es6id: 21.2.5.2
|
|
||||||
info: >
|
|
||||||
21.2.5.2 RegExp.prototype.exec ( string )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
6. Return RegExpBuiltinExec(R, S).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
9. ReturnIfAbrupt(sticky).
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /./;
|
|
||||||
Object.defineProperty(r, 'sticky', {
|
|
||||||
get: function() {
|
|
||||||
throw new Test262Error();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
|
||||||
r.exec();
|
|
||||||
});
|
|
@ -1,30 +0,0 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Behavior if error is thrown when accessing `sticky` property
|
|
||||||
es6id: 21.2.5.13
|
|
||||||
info: >
|
|
||||||
21.2.5.13 RegExp.prototype.test( S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
5. Let match be RegExpExec(R, string).
|
|
||||||
|
|
||||||
21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S )
|
|
||||||
|
|
||||||
[...]
|
|
||||||
8. Let sticky be ToBoolean(Get(R, "sticky")).
|
|
||||||
9. ReturnIfAbrupt(sticky).
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var r = /./;
|
|
||||||
|
|
||||||
Object.defineProperty(r, 'sticky', {
|
|
||||||
get: function() {
|
|
||||||
throw new Test262Error();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
|
||||||
r.test();
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user