mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 07:54:41 +02:00
Merge pull request #1500 from ljharb/matchall
Tests for String.prototype.matchAll
This commit is contained in:
commit
3e4f58dee4
@ -72,6 +72,11 @@ String.prototype.trimStart
|
|||||||
# https://github.com/tc39/proposal-numeric-separator
|
# https://github.com/tc39/proposal-numeric-separator
|
||||||
numeric-separator-literal
|
numeric-separator-literal
|
||||||
|
|
||||||
|
# String.prototype.matchAll
|
||||||
|
# https://github.com/tc39/proposal-string-matchall
|
||||||
|
String.prototype.matchAll
|
||||||
|
Symbol.matchAll
|
||||||
|
|
||||||
# Standard language features
|
# Standard language features
|
||||||
#
|
#
|
||||||
# Language features that have been included in a published version of the
|
# Language features that have been included in a published version of the
|
||||||
|
34
harness/compareIterator.js
Normal file
34
harness/compareIterator.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Compare the values of an iterator with an array of expected values
|
||||||
|
---*/
|
||||||
|
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// function* numbers() {
|
||||||
|
// yield 1;
|
||||||
|
// yield 2;
|
||||||
|
// yield 3;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// compareIterator(numbers(), [
|
||||||
|
// v => assert.sameValue(v, 1),
|
||||||
|
// v => assert.sameValue(v, 2),
|
||||||
|
// v => assert.sameValue(v, 3),
|
||||||
|
// ]);
|
||||||
|
//
|
||||||
|
assert.compareIterator = function(iter, validators, message) {
|
||||||
|
message = message || '';
|
||||||
|
|
||||||
|
var i, result;
|
||||||
|
for (i = 0; i < validators.length; i++) {
|
||||||
|
result = iter.next();
|
||||||
|
assert(!result.done, 'Expected ' + i + ' values(s). Instead iterator only produced ' + (i - 1) + ' value(s). ' + message);
|
||||||
|
validators[i](result.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = iter.next();
|
||||||
|
assert(result.done, 'Expected only ' + i + ' values(s). Instead iterator produced more. ' + message);
|
||||||
|
assert.sameValue(result.value, undefined, 'Expected value of `undefined` when iterator completes. ' + message);
|
||||||
|
}
|
@ -37,3 +37,18 @@ function testPropertyEscapes(regex, string, expression) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a function that will validate RegExp match result
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var validate = matchValidator(['b'], 1, 'abc');
|
||||||
|
// validate(/b/.exec('abc'));
|
||||||
|
//
|
||||||
|
function matchValidator(expectedEntries, expectedIndex, expectedInput) {
|
||||||
|
return function(match) {
|
||||||
|
assert.compareArray(match, expectedEntries, 'Match entries');
|
||||||
|
assert.sameValue(match.index, expectedIndex, 'Match index');
|
||||||
|
assert.sameValue(match.input, expectedInput, 'Match input');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
33
test/built-ins/RegExp/prototype/Symbol.matchAll/internal-regexp-lastindex-not-zero.js
vendored
Normal file
33
test/built-ins/RegExp/prototype/Symbol.matchAll/internal-regexp-lastindex-not-zero.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
Throws TypeError when internally created RegExp's lastIndex is not 0
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
3. Else,
|
||||||
|
a. Let matcher be RegExpCreate(R, "g").
|
||||||
|
b. If ? IsRegExp(matcher) is not true, throw a TypeError exception.
|
||||||
|
[...]
|
||||||
|
3. If Get(matcher, "lastIndex") is not 0, throw a TypeError exception.
|
||||||
|
features: [Symbol.match, Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
Object.defineProperty(RegExp.prototype, Symbol.match, {
|
||||||
|
get() {
|
||||||
|
this.lastIndex = 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
RegExp.prototype[Symbol.matchAll].call({}, '');
|
||||||
|
});
|
29
test/built-ins/RegExp/prototype/Symbol.matchAll/isregexp-internal-regexp-is-false.js
vendored
Normal file
29
test/built-ins/RegExp/prototype/Symbol.matchAll/isregexp-internal-regexp-is-false.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Throws TypeError when internally created RegExp's @@match is false
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
3. Else,
|
||||||
|
a. Let matcher be RegExpCreate(R, "g").
|
||||||
|
b. If ? IsRegExp(matcher) is not true, throw a TypeError exception.
|
||||||
|
features: [Symbol.match, Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
Object.defineProperty(RegExp.prototype, Symbol.match, {
|
||||||
|
get() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
RegExp.prototype[Symbol.matchAll].call({}, '');
|
||||||
|
});
|
29
test/built-ins/RegExp/prototype/Symbol.matchAll/isregexp-internal-regexp-throws.js
vendored
Normal file
29
test/built-ins/RegExp/prototype/Symbol.matchAll/isregexp-internal-regexp-throws.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors thrown while accessing @@match property
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
3. Else,
|
||||||
|
a. Let matcher be RegExpCreate(R, "g").
|
||||||
|
b. If ? IsRegExp(matcher) is not true, throw a TypeError exception.
|
||||||
|
features: [Symbol.match, Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
Object.defineProperty(RegExp.prototype, Symbol.match, {
|
||||||
|
get() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
RegExp.prototype[Symbol.matchAll].call({}, '');
|
||||||
|
});
|
26
test/built-ins/RegExp/prototype/Symbol.matchAll/isregexp-this-throws.js
vendored
Normal file
26
test/built-ins/RegExp/prototype/Symbol.matchAll/isregexp-this-throws.js
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors thrown while accessing RegExp's @@match property
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
features: [Symbol.match, Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = {
|
||||||
|
get [Symbol.match]() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
RegExp.prototype[Symbol.matchAll].call(obj, '');
|
||||||
|
});
|
30
test/built-ins/RegExp/prototype/Symbol.matchAll/length.js
vendored
Normal file
30
test/built-ins/RegExp/prototype/Symbol.matchAll/length.js
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: RegExp.prototype[Symbol.matchAll] `length` property
|
||||||
|
info: |
|
||||||
|
17 ECMAScript Standard Built-in Objects:
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Every built-in function object, including constructors, has a length
|
||||||
|
property whose value is an integer. Unless otherwise specified, this
|
||||||
|
value is equal to the largest number of named arguments shown in the
|
||||||
|
subclause headings for the function description. Optional parameters
|
||||||
|
(which are indicated with brackets: [ ]) or rest parameters (which
|
||||||
|
are shown using the form «...name») are not included in the default
|
||||||
|
argument count.
|
||||||
|
|
||||||
|
Unless otherwise specified, the length property of a built-in function
|
||||||
|
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
|
||||||
|
[[Configurable]]: true }.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(RegExp.prototype[Symbol.matchAll].length, 1);
|
||||||
|
|
||||||
|
verifyNotEnumerable(RegExp.prototype[Symbol.matchAll], 'length');
|
||||||
|
verifyNotWritable(RegExp.prototype[Symbol.matchAll], 'length');
|
||||||
|
verifyConfigurable(RegExp.prototype[Symbol.matchAll], 'length');
|
28
test/built-ins/RegExp/prototype/Symbol.matchAll/name.js
vendored
Normal file
28
test/built-ins/RegExp/prototype/Symbol.matchAll/name.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: RegExp.prototype[Symbol.matchAll] `name` property
|
||||||
|
info: |
|
||||||
|
17 ECMAScript Standard Built-in Objects:
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Every built-in function object, including constructors, that is not
|
||||||
|
identified as an anonymous function has a name property whose value
|
||||||
|
is a String.
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Unless otherwise specified, the name property of a built-in function
|
||||||
|
object, if it exists, has the attributes { [[Writable]]: false,
|
||||||
|
[[Enumerable]]: false, [[Configurable]]: true }.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(RegExp.prototype[Symbol.matchAll].name, '[Symbol.matchAll]');
|
||||||
|
|
||||||
|
verifyNotEnumerable(RegExp.prototype[Symbol.matchAll], 'name');
|
||||||
|
verifyNotWritable(RegExp.prototype[Symbol.matchAll], 'name');
|
||||||
|
verifyConfigurable(RegExp.prototype[Symbol.matchAll], 'name');
|
22
test/built-ins/RegExp/prototype/Symbol.matchAll/prop-desc.js
vendored
Normal file
22
test/built-ins/RegExp/prototype/Symbol.matchAll/prop-desc.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: RegExp.prototype[Symbol.matchAll] property descriptor
|
||||||
|
info: |
|
||||||
|
17 ECMAScript Standard Built-in Objects:
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Every other data property described in clauses 18 through 26 and in Annex
|
||||||
|
B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
|
||||||
|
[[Configurable]]: true } unless otherwise specified.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(typeof RegExp.prototype[Symbol.matchAll], 'function');
|
||||||
|
|
||||||
|
verifyNotEnumerable(RegExp.prototype, Symbol.matchAll);
|
||||||
|
verifyWritable(RegExp.prototype, Symbol.matchAll);
|
||||||
|
verifyConfigurable(RegExp.prototype, Symbol.matchAll);
|
29
test/built-ins/RegExp/prototype/Symbol.matchAll/regexpcreate-this-throws.js
vendored
Normal file
29
test/built-ins/RegExp/prototype/Symbol.matchAll/regexpcreate-this-throws.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors while creating an internal RegExp
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
3. Else,
|
||||||
|
a. Let R be RegExpCreate(R, "g").
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = {
|
||||||
|
toString() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
RegExp.prototype[Symbol.matchAll].call(obj, '');
|
||||||
|
});
|
||||||
|
|
32
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor-get-constructor-throws.js
vendored
Normal file
32
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor-get-constructor-throws.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
Re-throws errors thrown while accessing RegExp's constructor property
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
a. Let C be ? SpeciesConstructor(R, RegExp).
|
||||||
|
|
||||||
|
SpeciesConstructor ( O, defaultConstructor )
|
||||||
|
[...]
|
||||||
|
2. Let C be ? Get(O, "constructor").
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
Object.defineProperty(regexp, 'constructor', {
|
||||||
|
get(){
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
regexp[Symbol.matchAll]('');
|
||||||
|
});
|
31
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor-get-species-throws.js
vendored
Normal file
31
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor-get-species-throws.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors thrown while accessing of @@species property
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
a. Let C be ? SpeciesConstructor(R, RegExp).
|
||||||
|
|
||||||
|
SpeciesConstructor ( O, defaultConstructor )
|
||||||
|
[...]
|
||||||
|
2. Let C be ? Get(O, "constructor").
|
||||||
|
features: [Symbol.matchAll, Symbol.species]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
regexp.constructor = {
|
||||||
|
get [Symbol.species]() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
regexp[Symbol.matchAll]('');
|
||||||
|
});
|
41
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor-is-not-object-throws.js
vendored
Normal file
41
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor-is-not-object-throws.js
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Throws TypeError if `constructor` property is not an object
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
a. Let C be ? SpeciesConstructor(R, RegExp).
|
||||||
|
|
||||||
|
SpeciesConstructor ( O, defaultConstructor )
|
||||||
|
[...]
|
||||||
|
2. Let C be ? Get(O, "constructor").
|
||||||
|
3. If C is undefined, return defaultConstructor.
|
||||||
|
4. If Type(C) is not Object, throw a TypeError exception.
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
|
||||||
|
function callMatchAll() { regexp[Symbol.matchAll](''); }
|
||||||
|
|
||||||
|
regexp.constructor = null;
|
||||||
|
assert.throws(TypeError, callMatchAll, "`constructor` value is null");
|
||||||
|
|
||||||
|
regexp.constructor = true;
|
||||||
|
assert.throws(TypeError, callMatchAll, "`constructor` value is Boolean");
|
||||||
|
|
||||||
|
regexp.constructor = "";
|
||||||
|
assert.throws(TypeError, callMatchAll, "`constructor` value is String");
|
||||||
|
|
||||||
|
regexp.constructor = Symbol();
|
||||||
|
assert.throws(TypeError, callMatchAll, "`constructor` value is Symbol");
|
||||||
|
|
||||||
|
regexp.constructor = 1;
|
||||||
|
assert.throws(TypeError, callMatchAll, "`constructor` value is Number");
|
31
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor-is-undefined.js
vendored
Normal file
31
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor-is-undefined.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Throws TypeError if `constructor` property is not an object
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
a. Let C be ? SpeciesConstructor(R, RegExp).
|
||||||
|
|
||||||
|
SpeciesConstructor ( O, defaultConstructor )
|
||||||
|
[...]
|
||||||
|
2. Let C be ? Get(O, "constructor").
|
||||||
|
3. If C is undefined, return defaultConstructor.
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /\w/g;
|
||||||
|
regexp.constructor = undefined;
|
||||||
|
var str = 'a*b';
|
||||||
|
|
||||||
|
assert.compareIterator(regexp[Symbol.matchAll](str), [
|
||||||
|
matchValidator(['a'], 0, str),
|
||||||
|
matchValidator(['b'], 2, str)
|
||||||
|
]);
|
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: TypeError is thrown when species constructor is not a constructor
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
2. Return ? [MatchAllIterator](#matchalliterator)(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
3. Let C be ? [SpeciesConstructor][species-constructor](R, RegExp).
|
||||||
|
|
||||||
|
SpeciesConstructor ( O, defaultConstructor )
|
||||||
|
[...]
|
||||||
|
2. Let C be ? Get(O, "constructor").
|
||||||
|
3. If C is undefined, return defaultConstructor.
|
||||||
|
4. If Type(C) is not Object, throw a TypeError exception.
|
||||||
|
5. Let S be ? Get(C, @@species).
|
||||||
|
6. If S is either undefined or null, return defaultConstructor.
|
||||||
|
7. If IsConstructor(S) is true, return S.
|
||||||
|
8. Throw a TypeError exception.
|
||||||
|
features: [Symbol.matchAll, Symbol.species]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
var speciesConstructor = {};
|
||||||
|
regexp.constructor = speciesConstructor;
|
||||||
|
|
||||||
|
var callMatchAll = function() {
|
||||||
|
regexp[Symbol.matchAll]('');
|
||||||
|
}
|
||||||
|
|
||||||
|
speciesConstructor[Symbol.species] = true;
|
||||||
|
assert.throws(TypeError, callMatchAll, "`constructor[Symbol.species]` value is Boolean");
|
||||||
|
|
||||||
|
speciesConstructor[Symbol.species] = 1;
|
||||||
|
assert.throws(TypeError, callMatchAll, "`constructor[Symbol.species]` value is Number");
|
||||||
|
|
||||||
|
speciesConstructor[Symbol.species] = Symbol();
|
||||||
|
assert.throws(TypeError, callMatchAll, "`constructor[Symbol.species]` value is Symbol");
|
||||||
|
|
||||||
|
speciesConstructor[Symbol.species] = true;
|
||||||
|
assert.throws(TypeError, callMatchAll, "`constructor[Symbol.species]` value is Boolean");
|
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
Default constructor is used when species constructor is null or undefined
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
2. Return ? [MatchAllIterator](#matchalliterator)(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
3. Let C be ? [SpeciesConstructor][species-constructor](R, RegExp).
|
||||||
|
|
||||||
|
SpeciesConstructor ( O, defaultConstructor )
|
||||||
|
[...]
|
||||||
|
2. Let C be ? Get(O, "constructor").
|
||||||
|
3. If C is undefined, return defaultConstructor.
|
||||||
|
4. If Type(C) is not Object, throw a TypeError exception.
|
||||||
|
5. Let S be ? Get(C, @@species).
|
||||||
|
6. If S is either undefined or null, return defaultConstructor.
|
||||||
|
features: [Symbol.matchAll, Symbol.species]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function TestWithConstructor(ctor) {
|
||||||
|
var regexp = /\w/g;
|
||||||
|
regexp.constructor = {
|
||||||
|
[Symbol.species]: ctor
|
||||||
|
};
|
||||||
|
var str = 'a*b';
|
||||||
|
|
||||||
|
assert.compareIterator(regexp[Symbol.matchAll](str), [
|
||||||
|
matchValidator(['a'], 0, str),
|
||||||
|
matchValidator(['b'], 2, str)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
TestWithConstructor(undefined);
|
||||||
|
TestWithConstructor(null);
|
29
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor-species-throws.js
vendored
Normal file
29
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor-species-throws.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors when calling constructor's @@species
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
a. Let C be ? SpeciesConstructor(R, RegExp).
|
||||||
|
b. Let flags be ? ToString(? Get(R, "flags"))
|
||||||
|
c. Let matcher be ? Construct(C, R, flags).
|
||||||
|
features: [Symbol.matchAll, Symbol.species]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
regexp.constructor = {
|
||||||
|
[Symbol.species]: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
regexp[Symbol.matchAll]('');
|
||||||
|
});
|
42
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor.js
vendored
Normal file
42
test/built-ins/RegExp/prototype/Symbol.matchAll/species-constructor.js
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Custom species constructor is called when creating internal RegExp
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
a. Let C be ? SpeciesConstructor(R, RegExp).
|
||||||
|
b. Let flags be ? ToString(? Get(R, "flags"))
|
||||||
|
c. Let matcher be ? Construct(C, R, flags).
|
||||||
|
features: [Symbol.matchAll, Symbol.species]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
var callArgs;
|
||||||
|
var regexp = /\d/u;
|
||||||
|
regexp.constructor = {
|
||||||
|
[Symbol.species]: function(){
|
||||||
|
callCount++;
|
||||||
|
callArgs = arguments;
|
||||||
|
return /\w/g;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var str = 'a*b';
|
||||||
|
var iter = regexp[Symbol.matchAll](str);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
||||||
|
assert.sameValue(callArgs.length, 2);
|
||||||
|
assert.sameValue(callArgs[0], regexp);
|
||||||
|
assert.sameValue(callArgs[1], 'u');
|
||||||
|
|
||||||
|
assert.compareIterator(iter, [
|
||||||
|
matchValidator(['a'], 0, str),
|
||||||
|
matchValidator(['b'], 2, str)
|
||||||
|
]);
|
34
test/built-ins/RegExp/prototype/Symbol.matchAll/species-regexp-get-global-throws.js
vendored
Normal file
34
test/built-ins/RegExp/prototype/Symbol.matchAll/species-regexp-get-global-throws.js
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
Re-throws errors thrown while accessing species constructed RegExp's
|
||||||
|
global property
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
d. Let global be ? ToBoolean(? Get(matcher, "global")).
|
||||||
|
features: [Symbol.matchAll, Symbol.species]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
regexp.constructor = {
|
||||||
|
[Symbol.species]: function() {
|
||||||
|
return Object.defineProperty(/./, 'global', {
|
||||||
|
get() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
regexp[Symbol.matchAll]('');
|
||||||
|
});
|
34
test/built-ins/RegExp/prototype/Symbol.matchAll/species-regexp-get-unicode-throws.js
vendored
Normal file
34
test/built-ins/RegExp/prototype/Symbol.matchAll/species-regexp-get-unicode-throws.js
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
Re-throws errors thrown while accessing species constructed RegExp's
|
||||||
|
unicode property
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
e. Let fullUnicode be ? ToBoolean(? Get(matcher, "unicode")).
|
||||||
|
features: [Symbol.matchAll, Symbol.species]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
regexp.constructor = {
|
||||||
|
[Symbol.species]: function() {
|
||||||
|
return Object.defineProperty(/./, 'unicode', {
|
||||||
|
get() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
regexp[Symbol.matchAll]('');
|
||||||
|
});
|
27
test/built-ins/RegExp/prototype/Symbol.matchAll/string-tostring-throws.js
vendored
Normal file
27
test/built-ins/RegExp/prototype/Symbol.matchAll/string-tostring-throws.js
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: String coercion of string parameter
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
1. Let S be ? ToString(O).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = {
|
||||||
|
valueOf() {
|
||||||
|
$ERROR('This method should not be invoked.');
|
||||||
|
},
|
||||||
|
toString() {
|
||||||
|
throw new Test262Error('toString invoked');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
/toString value/[Symbol.matchAll](obj);
|
||||||
|
});
|
29
test/built-ins/RegExp/prototype/Symbol.matchAll/string-tostring.js
vendored
Normal file
29
test/built-ins/RegExp/prototype/Symbol.matchAll/string-tostring.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: String coercion of `string` argument
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
1. Let S be ? ToString(O).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var str = 'a*b';
|
||||||
|
var obj = {
|
||||||
|
toString() {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var regexp = /\w/g;
|
||||||
|
|
||||||
|
assert.compareIterator(regexp[Symbol.matchAll](obj), [
|
||||||
|
matchValidator(['a'], 0, str),
|
||||||
|
matchValidator(['b'], 2, str)
|
||||||
|
]);
|
||||||
|
|
28
test/built-ins/RegExp/prototype/Symbol.matchAll/this-get-flags-throws.js
vendored
Normal file
28
test/built-ins/RegExp/prototype/Symbol.matchAll/this-get-flags-throws.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors thrown while accessing RegExp's flags property
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
b. Let flags be ? ToString(? Get(R, "flags"))
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
Object.defineProperty(regexp, 'flags', {
|
||||||
|
get() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
regexp[Symbol.matchAll]('');
|
||||||
|
});
|
29
test/built-ins/RegExp/prototype/Symbol.matchAll/this-get-flags.js
vendored
Normal file
29
test/built-ins/RegExp/prototype/Symbol.matchAll/this-get-flags.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Regexp's flags
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
b. Let flags be ? ToString(? Get(R, "flags"))
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /\w/;
|
||||||
|
Object.defineProperty(regexp, 'flags', {
|
||||||
|
value: 'g'
|
||||||
|
});
|
||||||
|
var str = 'a*b';
|
||||||
|
|
||||||
|
assert.compareIterator(regexp[Symbol.matchAll](str), [
|
||||||
|
matchValidator(['a'], 0, str),
|
||||||
|
matchValidator(['b'], 2, str)
|
||||||
|
]);
|
36
test/built-ins/RegExp/prototype/Symbol.matchAll/this-lastindex-cached.js
vendored
Normal file
36
test/built-ins/RegExp/prototype/Symbol.matchAll/this-lastindex-cached.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Verify regexp's lastIndex is cached
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
f. Let lastIndex be ? ToLength(? Get(R, "lastIndex")).
|
||||||
|
g. Perform ? Set(matcher, "lastIndex", lastIndex, true).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./g;
|
||||||
|
regexp.lastIndex = {
|
||||||
|
valueOf() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var str = 'abcd';
|
||||||
|
var iter = regexp[Symbol.matchAll](str);
|
||||||
|
|
||||||
|
// Verify lastIndex is cached at the time of calling @@matchAll
|
||||||
|
regexp.lastIndex = 0;
|
||||||
|
|
||||||
|
assert.compareIterator(iter, [
|
||||||
|
matchValidator(['c'], 2, str),
|
||||||
|
matchValidator(['d'], 3, str)
|
||||||
|
]);
|
31
test/built-ins/RegExp/prototype/Symbol.matchAll/this-not-object-throws.js
vendored
Normal file
31
test/built-ins/RegExp/prototype/Symbol.matchAll/this-not-object-throws.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Throws TypeError when `this` is not an Object
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
1. Let R be the this value.
|
||||||
|
2. If Type(R) is not Object, throw a TypeError exception.
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thisValue;
|
||||||
|
var callMatchAll = function() {
|
||||||
|
RegExp.prototype[Symbol.matchAll].call(thisValue, '');
|
||||||
|
};
|
||||||
|
|
||||||
|
thisValue = null;
|
||||||
|
assert.throws(TypeError, callMatchAll, 'this value is null');
|
||||||
|
|
||||||
|
thisValue = true;
|
||||||
|
assert.throws(TypeError, callMatchAll, 'this value is Boolean');
|
||||||
|
|
||||||
|
thisValue = '';
|
||||||
|
assert.throws(TypeError, callMatchAll, 'this value is String');
|
||||||
|
|
||||||
|
thisValue = Symbol();
|
||||||
|
assert.throws(TypeError, callMatchAll, 'this value is Symbol');
|
||||||
|
|
||||||
|
thisValue = 1;
|
||||||
|
assert.throws(TypeError, callMatchAll, 'this value is Number');
|
28
test/built-ins/RegExp/prototype/Symbol.matchAll/this-tolength-lastindex-throws.js
vendored
Normal file
28
test/built-ins/RegExp/prototype/Symbol.matchAll/this-tolength-lastindex-throws.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors while coercing RegExp's lastIndex
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
f. Let lastIndex be ? ToLength(? Get(R, "lastIndex")).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
regexp.lastIndex = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
regexp[Symbol.matchAll]('');
|
||||||
|
});
|
33
test/built-ins/RegExp/prototype/Symbol.matchAll/this-tostring-flags-throws.js
vendored
Normal file
33
test/built-ins/RegExp/prototype/Symbol.matchAll/this-tostring-flags-throws.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors while coercing RegExp's flags to a string
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
b. Let flags be ? ToString(? Get(R, "flags"))
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /\w/;
|
||||||
|
Object.defineProperty(regexp, 'flags', {
|
||||||
|
value: {
|
||||||
|
valueOf() {
|
||||||
|
ERROR('valueOf Should not be called');
|
||||||
|
},
|
||||||
|
toString() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
regexp[Symbol.matchAll]('');
|
||||||
|
});
|
33
test/built-ins/RegExp/prototype/Symbol.matchAll/this-tostring-flags.js
vendored
Normal file
33
test/built-ins/RegExp/prototype/Symbol.matchAll/this-tostring-flags.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Corercing regexp's flags
|
||||||
|
info: |
|
||||||
|
RegExp.prototype [ @@matchAll ] ( string )
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(R, string).
|
||||||
|
|
||||||
|
MatchAllIterator ( R, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(R) is true, then
|
||||||
|
[...]
|
||||||
|
b. Let flags be ? ToString(? Get(R, "flags"))
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /\w/;
|
||||||
|
Object.defineProperty(regexp, 'flags', {
|
||||||
|
value: {
|
||||||
|
toString() {
|
||||||
|
return 'g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var str = 'a*b';
|
||||||
|
|
||||||
|
assert.compareIterator(regexp[Symbol.matchAll](str), [
|
||||||
|
matchValidator(['a'], 0, str),
|
||||||
|
matchValidator(['b'], 2, str)
|
||||||
|
]);
|
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
`Symbol.toStringTag` property descriptor
|
||||||
|
info: |
|
||||||
|
The initial value of the @@toStringTag property is the string value "String
|
||||||
|
Iterator".
|
||||||
|
|
||||||
|
This property has the attributes { [[Writable]]: false, [[Enumerable]]:
|
||||||
|
false, [[Configurable]]: true }.
|
||||||
|
features: [Symbol.matchAll, Symbol.toStringTag]
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var RegExpStringIteratorProto = Object.getPrototypeOf(/./[Symbol.matchAll](''));
|
||||||
|
|
||||||
|
assert.sameValue(RegExpStringIteratorProto[Symbol.toStringTag], 'RegExp String Iterator');
|
||||||
|
|
||||||
|
verifyNotEnumerable(RegExpStringIteratorProto, Symbol.toStringTag);
|
||||||
|
verifyNotWritable(RegExpStringIteratorProto, Symbol.toStringTag);
|
||||||
|
verifyConfigurable(RegExpStringIteratorProto, Symbol.toStringTag);
|
16
test/built-ins/RegExpStringIteratorPrototype/ancestry.js
Normal file
16
test/built-ins/RegExpStringIteratorPrototype/ancestry.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
The [[Prototype]] internal slot ofthe %RegExpStringIteratorPrototype% is the
|
||||||
|
%IteratorPrototype% intrinsic object (25.1.2).
|
||||||
|
features: [Symbol.iterator, Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var RegExpStringIteratorProto = Object.getPrototypeOf(/./[Symbol.matchAll]('a'));
|
||||||
|
var ArrayIteratorProto = Object.getPrototypeOf(
|
||||||
|
Object.getPrototypeOf([][Symbol.iterator]())
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Object.getPrototypeOf(RegExpStringIteratorProto), ArrayIteratorProto);
|
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors when calling exec
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
[...]
|
||||||
|
9. Let match be ? RegExpExec(R, S).
|
||||||
|
|
||||||
|
Runtime Semantics: RegExpExec ( R, S )
|
||||||
|
1. Assert: Type(R) is Object.
|
||||||
|
2. Assert: Type(S) is String.
|
||||||
|
3. Let exec be ? Get(R, "exec").
|
||||||
|
4. If IsCallable(exec) is true, then
|
||||||
|
a. Let result be ? Call(exec, R, « S »).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iter = /./[Symbol.matchAll]('');
|
||||||
|
|
||||||
|
RegExp.prototype.exec = function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
iter.next();
|
||||||
|
});
|
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors thrown while accessing RegExp's exec property
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
[...]
|
||||||
|
9. Let match be ? RegExpExec(R, S).
|
||||||
|
|
||||||
|
Runtime Semantics: RegExpExec ( R, S )
|
||||||
|
1. Assert: Type(R) is Object.
|
||||||
|
2. Assert: Type(S) is String.
|
||||||
|
3. Let exec be ? Get(R, "exec").
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iter = /./[Symbol.matchAll]('');
|
||||||
|
|
||||||
|
Object.defineProperty(RegExp.prototype, 'exec', {
|
||||||
|
get() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
iter.next();
|
||||||
|
});
|
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors thrown while accessing the first match
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
[...]
|
||||||
|
9. Let match be ? RegExpExec(R, S).
|
||||||
|
10. If match is null, then
|
||||||
|
[...]
|
||||||
|
11. Else,
|
||||||
|
a. If global is true,
|
||||||
|
i. Let matchStr be ? ToString(? Get(match, "0")).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iter = /./g[Symbol.matchAll]('');
|
||||||
|
|
||||||
|
RegExp.prototype.exec = function() {
|
||||||
|
return {
|
||||||
|
get '0'() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
iter.next();
|
||||||
|
});
|
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors thrown from coercing first match to a string
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
[...]
|
||||||
|
9. Let match be ? RegExpExec(R, S).
|
||||||
|
10. If match is null, then
|
||||||
|
[...]
|
||||||
|
11. Else,
|
||||||
|
a. If global is true,
|
||||||
|
i. Let matchStr be ? ToString(? Get(match, "0")).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iter = /./g[Symbol.matchAll]('');
|
||||||
|
|
||||||
|
RegExp.prototype.exec = function() {
|
||||||
|
return [{
|
||||||
|
toString: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
iter.next();
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Behavior when first match is coerced to a empty string
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
[...]
|
||||||
|
9. Let match be ? RegExpExec(R, S).
|
||||||
|
10. If match is null, then
|
||||||
|
[...]
|
||||||
|
11. Else,
|
||||||
|
a. If global is true,
|
||||||
|
i. Let matchStr be ? ToString(? Get(match, "0")).
|
||||||
|
ii. If matchStr is the empty string,
|
||||||
|
1. Let thisIndex be ? ToLength(? Get(R, "lastIndex").
|
||||||
|
2. Let nextIndex be ! AdvanceStringIndex(S, thisIndex, fullUnicode).
|
||||||
|
3. Perform ? Set(R, "lastIndex", nextIndex, true).
|
||||||
|
iii. Return ! CreateIterResultObject(match, false).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iter = /./g[Symbol.matchAll]('');
|
||||||
|
|
||||||
|
var execResult = {
|
||||||
|
get '0'() {
|
||||||
|
return {
|
||||||
|
toString() { return ''; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var internalRegExp;
|
||||||
|
RegExp.prototype.exec = function () {
|
||||||
|
internalRegExp = this;
|
||||||
|
return execResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = iter.next();
|
||||||
|
assert.sameValue(internalRegExp.lastIndex, 1);
|
||||||
|
assert.sameValue(result.value, execResult);
|
||||||
|
assert(!result.done);
|
||||||
|
|
||||||
|
|
||||||
|
result = iter.next();
|
||||||
|
assert.sameValue(internalRegExp.lastIndex, 2);
|
||||||
|
assert.sameValue(result.value, execResult);
|
||||||
|
assert(!result.done);
|
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Behavior with a custom RegExp exec
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
[...]
|
||||||
|
9. Let match be ? RegExpExec(R, S).
|
||||||
|
|
||||||
|
Runtime Semantics: RegExpExec ( R, S )
|
||||||
|
1. Assert: Type(R) is Object.
|
||||||
|
2. Assert: Type(S) is String.
|
||||||
|
3. Let exec be ? Get(R, "exec").
|
||||||
|
4. If IsCallable(exec) is true, then
|
||||||
|
[...]
|
||||||
|
5. If R does not have a [[RegExpMatcher]] internal slot, throw a
|
||||||
|
TypeError exception.
|
||||||
|
6. Return ? RegExpBuiltinExec(R, S).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function TestWithRegExpExec(exec) {
|
||||||
|
RegExp.prototype.exec = exec;
|
||||||
|
|
||||||
|
var regexp = /\w/g;
|
||||||
|
var str = 'a*b';
|
||||||
|
|
||||||
|
assert.compareIterator(regexp[Symbol.matchAll](str), [
|
||||||
|
matchValidator(['a'], 0, str),
|
||||||
|
matchValidator(['b'], 2, str)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
TestWithRegExpExec(undefined);
|
||||||
|
TestWithRegExpExec(null);
|
||||||
|
TestWithRegExpExec(5);
|
||||||
|
TestWithRegExpExec(true);
|
||||||
|
TestWithRegExpExec(Symbol());
|
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Behavior with a custom RegExp exec
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
[...]
|
||||||
|
9. Let match be ? RegExpExec(R, S).
|
||||||
|
|
||||||
|
Runtime Semantics: RegExpExec ( R, S )
|
||||||
|
1. Assert: Type(R) is Object.
|
||||||
|
2. Assert: Type(S) is String.
|
||||||
|
3. Let exec be ? Get(R, "exec").
|
||||||
|
4. If IsCallable(exec) is true, then
|
||||||
|
a. Let result be ? Call(exec, R, « S »).
|
||||||
|
b. If Type(result) is neither Object or Null, throw a TypeError exception.
|
||||||
|
c. Return result.
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./g;
|
||||||
|
var str = 'abc';
|
||||||
|
var iter = regexp[Symbol.matchAll](str);
|
||||||
|
|
||||||
|
var callArgs, callCount;
|
||||||
|
function callNextWithExecReturnValue(returnValue) {
|
||||||
|
callArgs = undefined;
|
||||||
|
callCount = 0;
|
||||||
|
|
||||||
|
RegExp.prototype.exec = function() {
|
||||||
|
callArgs = arguments;
|
||||||
|
callCount++;
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iter.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstExecReturnValue = ['ab'];
|
||||||
|
var result = callNextWithExecReturnValue(firstExecReturnValue);
|
||||||
|
assert.sameValue(result.value, firstExecReturnValue);
|
||||||
|
assert(!result.done);
|
||||||
|
|
||||||
|
assert.sameValue(callArgs.length, 1);
|
||||||
|
assert.sameValue(callArgs[0], str);
|
||||||
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
|
result = callNextWithExecReturnValue(null);
|
||||||
|
assert.sameValue(result.value, undefined);
|
||||||
|
assert(result.done);
|
||||||
|
|
||||||
|
assert.sameValue(callArgs.length, 1);
|
||||||
|
assert.sameValue(callArgs[0], str);
|
||||||
|
assert.sameValue(callCount, 1);
|
33
test/built-ins/RegExpStringIteratorPrototype/next/length.js
Normal file
33
test/built-ins/RegExpStringIteratorPrototype/next/length.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
%RegExpStringIteratorPrototype%.next `length` property
|
||||||
|
info: |
|
||||||
|
17 ECMAScript Standard Built-in Objects:
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Every built-in function object, including constructors, has a length
|
||||||
|
property whose value is an integer. Unless otherwise specified, this
|
||||||
|
value is equal to the largest number of named arguments shown in the
|
||||||
|
subclause headings for the function description. Optional parameters
|
||||||
|
(which are indicated with brackets: [ ]) or rest parameters (which
|
||||||
|
are shown using the form «...name») are not included in the default
|
||||||
|
argument count.
|
||||||
|
|
||||||
|
Unless otherwise specified, the length property of a built-in function
|
||||||
|
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
|
||||||
|
[[Configurable]]: true }.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var RegExpStringIteratorProto = Object.getPrototypeOf(/./[Symbol.matchAll](''));
|
||||||
|
|
||||||
|
assert.sameValue(RegExpStringIteratorProto.next.length, 0);
|
||||||
|
|
||||||
|
verifyNotEnumerable(RegExpStringIteratorProto.next, 'length');
|
||||||
|
verifyNotWritable(RegExpStringIteratorProto.next, 'length');
|
||||||
|
verifyConfigurable(RegExpStringIteratorProto.next, 'length');
|
31
test/built-ins/RegExpStringIteratorPrototype/next/name.js
Normal file
31
test/built-ins/RegExpStringIteratorPrototype/next/name.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
%RegExpStringIteratorPrototype%.next `name` property
|
||||||
|
info: |
|
||||||
|
17 ECMAScript Standard Built-in Objects:
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Every built-in function object, including constructors, that is not
|
||||||
|
identified as an anonymous function has a name property whose value
|
||||||
|
is a String.
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Unless otherwise specified, the name property of a built-in function
|
||||||
|
object, if it exists, has the attributes { [[Writable]]: false,
|
||||||
|
[[Enumerable]]: false, [[Configurable]]: true }.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var RegExpStringIteratorProto = Object.getPrototypeOf(/./[Symbol.matchAll](''));
|
||||||
|
|
||||||
|
assert.sameValue(RegExpStringIteratorProto.next.name, 'next');
|
||||||
|
|
||||||
|
verifyNotEnumerable(RegExpStringIteratorProto.next, 'name');
|
||||||
|
verifyNotWritable(RegExpStringIteratorProto.next, 'name');
|
||||||
|
verifyConfigurable(RegExpStringIteratorProto.next, 'name');
|
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Iterates over each match
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
[...]
|
||||||
|
4. If O.[[Done]] is true, then
|
||||||
|
a. Return ! reateIterResultObject(undefined, true).
|
||||||
|
[...]
|
||||||
|
9. Let match be ? RegExpExec(R, S).
|
||||||
|
10. If match is null, then
|
||||||
|
a. Set O.[[Done]] to true.
|
||||||
|
b. Return ! CreateIterResultObject(undefined, true).
|
||||||
|
11. Else,
|
||||||
|
a. If global is true,
|
||||||
|
i. Let matchStr be ? ToString(? Get(match, "0")).
|
||||||
|
ii. If matchStr is the empty string,
|
||||||
|
1. Let thisIndex be ? ToLength(? Get(R, "lastIndex").
|
||||||
|
2. Let nextIndex be ! AdvanceStringIndex(S, thisIndex, fullUnicode).
|
||||||
|
3. Perform ? Set(R, "lastIndex", nextIndex, true).
|
||||||
|
iii. Return ! CreateIterResultObject(match, false).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /\w/g;
|
||||||
|
var str = 'a*b';
|
||||||
|
var iter = regexp[Symbol.matchAll](str);
|
||||||
|
|
||||||
|
assert.compareIterator(iter, [
|
||||||
|
matchValidator(['a'], 0, str),
|
||||||
|
matchValidator(['b'], 2, str)
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Verifies %RegExpStringIteratorPrototype%.next() step 4
|
||||||
|
var result = iter.next();
|
||||||
|
assert.sameValue(result.value, undefined);
|
||||||
|
assert(result.done);
|
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Iterates over the first match
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
[...]
|
||||||
|
4. If O.[[Done]] is true, then
|
||||||
|
a. Return ! reateIterResultObject(undefined, true).
|
||||||
|
[...]
|
||||||
|
9. Let match be ? RegExpExec(R, S).
|
||||||
|
10. If match is null, then
|
||||||
|
a. Set O.[[Done]] to true.
|
||||||
|
b. Return ! CreateIterResultObject(undefined, true).
|
||||||
|
11. Else,
|
||||||
|
a. If global is true,
|
||||||
|
[...]
|
||||||
|
b. Else,
|
||||||
|
i. Set O.[[Done]] to true.
|
||||||
|
ii. Return ! CreateIterResultObject(match, false).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /\w/;
|
||||||
|
var str = '*a*b';
|
||||||
|
var iter = regexp[Symbol.matchAll](str);
|
||||||
|
|
||||||
|
assert.compareIterator(iter, [
|
||||||
|
matchValidator(['a'], 1, str)
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Verifies %RegExpStringIteratorPrototype%.next() step 4
|
||||||
|
var result = iter.next();
|
||||||
|
assert.sameValue(result.value, undefined);
|
||||||
|
assert(result.done);
|
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Throws TypeError when `this` does not have all internal slots
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
1. Let O be the this value.
|
||||||
|
2. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
3. If O does not have all of the internal slots of a RegExp String Iterator
|
||||||
|
Object Instance (see PropertiesOfRegExpStringIteratorInstances), throw a
|
||||||
|
TypeError.
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iterator = /./[Symbol.matchAll]('');
|
||||||
|
var object = Object.create(iterator);
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
object.next();
|
||||||
|
});
|
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
%RegExpStringIteratorPrototype%.next property descriptor
|
||||||
|
info: |
|
||||||
|
17 ECMAScript Standard Built-in Objects:
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Every other data property described in clauses 18 through 26 and in Annex
|
||||||
|
B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
|
||||||
|
[[Configurable]]: true } unless otherwise specified.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var RegExpStringIteratorProto = Object.getPrototypeOf(/./[Symbol.matchAll](''));
|
||||||
|
|
||||||
|
assert.sameValue(typeof RegExpStringIteratorProto.next, 'function');
|
||||||
|
|
||||||
|
verifyNotEnumerable(RegExpStringIteratorProto, 'next');
|
||||||
|
verifyWritable(RegExpStringIteratorProto, 'next');
|
||||||
|
verifyConfigurable(RegExpStringIteratorProto, 'next');
|
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors thrown coercing RegExp's lastIndex to a length
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
[...]
|
||||||
|
9. Let match be ? RegExpExec(R, S).
|
||||||
|
10. If match is null, then
|
||||||
|
[...]
|
||||||
|
11. Else,
|
||||||
|
a. If global is true,
|
||||||
|
i. Let matchStr be ? ToString(? Get(match, "0")).
|
||||||
|
ii. If matchStr is the empty string,
|
||||||
|
1. Let thisIndex be ? ToLength(? Get(R, "lastIndex").
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iter = /./g[Symbol.matchAll]('');
|
||||||
|
|
||||||
|
RegExp.prototype.exec = function() {
|
||||||
|
this.lastIndex = {
|
||||||
|
valueOf() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return [''];
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
iter.next();
|
||||||
|
});
|
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Throws TypeError when `this` is not an Object
|
||||||
|
info: |
|
||||||
|
%RegExpStringIteratorPrototype%.next ( )
|
||||||
|
1. Let O be the this value.
|
||||||
|
2. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var RegExpStringIteratorProto = Object.getPrototypeOf(/./[Symbol.matchAll](''));
|
||||||
|
|
||||||
|
var thisValue;
|
||||||
|
var callNext = function() {
|
||||||
|
RegExpStringIteratorProto.next.call(thisValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
thisValue = null;
|
||||||
|
assert.throws(TypeError, callNext, 'this value is null');
|
||||||
|
|
||||||
|
thisValue = true;
|
||||||
|
assert.throws(TypeError, callNext, 'this value is Boolean');
|
||||||
|
|
||||||
|
thisValue = '';
|
||||||
|
assert.throws(TypeError, callNext, 'this value is String');
|
||||||
|
|
||||||
|
thisValue = Symbol();
|
||||||
|
assert.throws(TypeError, callNext, 'this value is Symbol');
|
||||||
|
|
||||||
|
thisValue = 1;
|
||||||
|
assert.throws(TypeError, callNext, 'this value is Number');
|
||||||
|
|
30
test/built-ins/String/prototype/matchAll/length.js
vendored
Normal file
30
test/built-ins/String/prototype/matchAll/length.js
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: String.prototype.matchAll `length` property
|
||||||
|
info: |
|
||||||
|
17 ECMAScript Standard Built-in Objects:
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Every built-in function object, including constructors, has a length
|
||||||
|
property whose value is an integer. Unless otherwise specified, this
|
||||||
|
value is equal to the largest number of named arguments shown in the
|
||||||
|
subclause headings for the function description. Optional parameters
|
||||||
|
(which are indicated with brackets: [ ]) or rest parameters (which
|
||||||
|
are shown using the form «...name») are not included in the default
|
||||||
|
argument count.
|
||||||
|
|
||||||
|
Unless otherwise specified, the length property of a built-in function
|
||||||
|
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
|
||||||
|
[[Configurable]]: true }.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [String.prototype.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(String.prototype.matchAll.length, 1);
|
||||||
|
|
||||||
|
verifyNotEnumerable(String.prototype.matchAll, 'length');
|
||||||
|
verifyNotWritable(String.prototype.matchAll, 'length');
|
||||||
|
verifyConfigurable(String.prototype.matchAll, 'length');
|
28
test/built-ins/String/prototype/matchAll/name.js
vendored
Normal file
28
test/built-ins/String/prototype/matchAll/name.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: String.prototype.matchAll `name` property
|
||||||
|
info: |
|
||||||
|
17 ECMAScript Standard Built-in Objects:
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Every built-in function object, including constructors, that is not
|
||||||
|
identified as an anonymous function has a name property whose value
|
||||||
|
is a String.
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Unless otherwise specified, the name property of a built-in function
|
||||||
|
object, if it exists, has the attributes { [[Writable]]: false,
|
||||||
|
[[Enumerable]]: false, [[Configurable]]: true }.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [String.prototype.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(String.prototype.matchAll.name, 'matchAll');
|
||||||
|
|
||||||
|
verifyNotEnumerable(String.prototype.matchAll, 'name');
|
||||||
|
verifyNotWritable(String.prototype.matchAll, 'name');
|
||||||
|
verifyConfigurable(String.prototype.matchAll, 'name');
|
22
test/built-ins/String/prototype/matchAll/prop-desc.js
vendored
Normal file
22
test/built-ins/String/prototype/matchAll/prop-desc.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: String.prototype.matchAll property descriptor
|
||||||
|
info: |
|
||||||
|
17 ECMAScript Standard Built-in Objects:
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
Every other data property described in clauses 18 through 26 and in Annex
|
||||||
|
B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
|
||||||
|
[[Configurable]]: true } unless otherwise specified.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [String.prototype.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(typeof String.prototype.matchAll, 'function');
|
||||||
|
|
||||||
|
verifyNotEnumerable(String.prototype, 'matchAll');
|
||||||
|
verifyWritable(String.prototype, 'matchAll');
|
||||||
|
verifyConfigurable(String.prototype, 'matchAll');
|
25
test/built-ins/String/prototype/matchAll/regexp-get-matchAll-throws.js
vendored
Normal file
25
test/built-ins/String/prototype/matchAll/regexp-get-matchAll-throws.js
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors when calling @@matchAll
|
||||||
|
info: |
|
||||||
|
String.prototype.matchAll ( regexp )
|
||||||
|
[...]
|
||||||
|
2. If regexp is neither undefined nor null, then
|
||||||
|
a. Let matcher be ? GetMethod(regexp, @@matchAll).
|
||||||
|
b. If matcher is not undefined, then
|
||||||
|
i. Return ? Call(matcher, regexp, « O »).
|
||||||
|
features: [Symbol.matchAll, String.prototype.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
Object.defineProperty(regexp, Symbol.matchAll, {
|
||||||
|
get() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
''.matchAll(regexp);
|
||||||
|
});
|
27
test/built-ins/String/prototype/matchAll/regexp-is-null.js
vendored
Normal file
27
test/built-ins/String/prototype/matchAll/regexp-is-null.js
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Behavior when regexp is null
|
||||||
|
info: |
|
||||||
|
String.prototype.matchAll ( regexp )
|
||||||
|
1. Let O be ? RequireObjectCoercible(this value).
|
||||||
|
2. If regexp is neither undefined nor null, then
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(regexp, O).
|
||||||
|
|
||||||
|
MatchAllIterator( regexp, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(regexp) is true, then
|
||||||
|
[...]
|
||||||
|
3. Else,
|
||||||
|
a. Let R be RegExpCreate(regexp, "g").
|
||||||
|
features: [String.prototype.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var str = '-null-';
|
||||||
|
|
||||||
|
assert.compareIterator(str.matchAll(null), [
|
||||||
|
matchValidator(['null'], 1, str)
|
||||||
|
]);
|
28
test/built-ins/String/prototype/matchAll/regexp-is-undefined.js
vendored
Normal file
28
test/built-ins/String/prototype/matchAll/regexp-is-undefined.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Behavior when regexp is null
|
||||||
|
info: |
|
||||||
|
String.prototype.matchAll ( regexp )
|
||||||
|
1. Let O be ? RequireObjectCoercible(this value).
|
||||||
|
2. If regexp is neither undefined nor null, then
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(regexp, O).
|
||||||
|
|
||||||
|
MatchAllIterator( regexp, O )
|
||||||
|
[...]
|
||||||
|
2. If ? IsRegExp(regexp) is true, then
|
||||||
|
[...]
|
||||||
|
3. Else,
|
||||||
|
a. Let R be RegExpCreate(regexp, "g").
|
||||||
|
features: [String.prototype.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var str = 'a';
|
||||||
|
|
||||||
|
assert.compareIterator(str.matchAll(undefined), [
|
||||||
|
matchValidator([''], 0, str),
|
||||||
|
matchValidator([''], 1, str)
|
||||||
|
]);
|
35
test/built-ins/String/prototype/matchAll/regexp-matchAll-invocation.js
vendored
Normal file
35
test/built-ins/String/prototype/matchAll/regexp-matchAll-invocation.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Invocation of @@matchAll property of user-supplied RegExp objects
|
||||||
|
info: |
|
||||||
|
String.prototype.matchAll ( regexp )
|
||||||
|
[...]
|
||||||
|
2. If regexp is neither undefined nor null, then
|
||||||
|
a. Let matcher be ? GetMethod(regexp, @@matchAll).
|
||||||
|
b. If matcher is not undefined, then
|
||||||
|
i. Return ? Call(matcher, regexp, « O »).
|
||||||
|
features: [Symbol.matchAll, String.prototype.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = {};
|
||||||
|
var returnVal = {};
|
||||||
|
var callCount = 0;
|
||||||
|
var thisVal, args;
|
||||||
|
|
||||||
|
obj[Symbol.matchAll] = function () {
|
||||||
|
callCount++;
|
||||||
|
thisVal = this;
|
||||||
|
args = arguments;
|
||||||
|
return returnVal;
|
||||||
|
};
|
||||||
|
|
||||||
|
var str = '';
|
||||||
|
|
||||||
|
assert.sameValue(str.matchAll(obj), returnVal);
|
||||||
|
assert.sameValue(callCount, 1, 'Invokes the method exactly once');
|
||||||
|
assert.sameValue(thisVal, obj);
|
||||||
|
assert.notSameValue(args, undefined);
|
||||||
|
assert.sameValue(args.length, 1);
|
||||||
|
assert.sameValue(args[0], str);
|
21
test/built-ins/String/prototype/matchAll/regexp-matchAll-throws.js
vendored
Normal file
21
test/built-ins/String/prototype/matchAll/regexp-matchAll-throws.js
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors when calling @@matchAll
|
||||||
|
info: |
|
||||||
|
String.prototype.matchAll ( regexp )
|
||||||
|
[...]
|
||||||
|
2. If regexp is neither undefined nor null, then
|
||||||
|
a. Let matcher be ? GetMethod(regexp, @@matchAll).
|
||||||
|
features: [Symbol.matchAll, String.prototype.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
regexp[Symbol.matchAll] = function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
''.matchAll(regexp);
|
||||||
|
});
|
22
test/built-ins/String/prototype/matchAll/regexp-prototype-get-matchAll-throws.js
vendored
Normal file
22
test/built-ins/String/prototype/matchAll/regexp-prototype-get-matchAll-throws.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors thrown while accessing RegExp's @@matchAll property
|
||||||
|
info: |
|
||||||
|
String.prototype.matchAll ( regexp )
|
||||||
|
[...]
|
||||||
|
2. If regexp is neither undefined nor null, then
|
||||||
|
a. Let matcher be ? GetMethod(regexp, @@matchAll).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
Object.defineProperty(RegExp.prototype, Symbol.matchAll, {
|
||||||
|
get() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
''.matchAll(/./);
|
||||||
|
});
|
24
test/built-ins/String/prototype/matchAll/regexp-prototype-has-no-matchAll.js
vendored
Normal file
24
test/built-ins/String/prototype/matchAll/regexp-prototype-has-no-matchAll.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Behavior when @@matchAll is removed from RegExp's prototype
|
||||||
|
info: |
|
||||||
|
String.prototype.matchAll ( regexp )
|
||||||
|
1. Let O be ? RequireObjectCoercible(this value).
|
||||||
|
2. If regexp is neither undefined nor null, then
|
||||||
|
a. Let matcher be ? GetMethod(regexp, @@matchAll).
|
||||||
|
b. If matcher is not undefined, then
|
||||||
|
[...]
|
||||||
|
3. Return ? MatchAllIterator(regexp, O).
|
||||||
|
features: [Symbol.matchAll, String.prototype.matchAll]
|
||||||
|
includes: [compareArray.js, compareIterator.js, regExpUtils.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
delete RegExp.prototype[Symbol.matchAll];
|
||||||
|
var str = 'a*b';
|
||||||
|
|
||||||
|
assert.compareIterator(str.matchAll(/\w/g), [
|
||||||
|
matchValidator(['a'], 0, str),
|
||||||
|
matchValidator(['b'], 2, str)
|
||||||
|
]);
|
36
test/built-ins/String/prototype/matchAll/regexp-prototype-matchAll-invocation.js
vendored
Normal file
36
test/built-ins/String/prototype/matchAll/regexp-prototype-matchAll-invocation.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Behavior when invoking of @@matchAll
|
||||||
|
info: |
|
||||||
|
String.prototype.matchAll ( regexp )
|
||||||
|
[...]
|
||||||
|
2. If regexp is neither undefined nor null, then
|
||||||
|
a. Let matcher be ? GetMethod(regexp, @@matchAll).
|
||||||
|
b. If matcher is not undefined, then
|
||||||
|
i. Return ? Call(matcher, regexp, « O »).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = {};
|
||||||
|
var returnVal = {};
|
||||||
|
var callCount = 0;
|
||||||
|
var thisVal, args;
|
||||||
|
|
||||||
|
RegExp.prototype[Symbol.matchAll] = function() {
|
||||||
|
callCount++;
|
||||||
|
thisVal = this;
|
||||||
|
args = arguments;
|
||||||
|
return returnVal;
|
||||||
|
};
|
||||||
|
|
||||||
|
var regexp = /./;
|
||||||
|
var str = '';
|
||||||
|
|
||||||
|
assert.sameValue(str.matchAll(regexp), returnVal);
|
||||||
|
assert.sameValue(callCount, 1, 'Invokes the method exactly once');
|
||||||
|
assert.sameValue(thisVal, regexp);
|
||||||
|
assert.notSameValue(args, undefined);
|
||||||
|
assert.sameValue(args.length, 1);
|
||||||
|
assert.sameValue(args[0], str);
|
22
test/built-ins/String/prototype/matchAll/regexp-prototype-matchAll-throws.js
vendored
Normal file
22
test/built-ins/String/prototype/matchAll/regexp-prototype-matchAll-throws.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Re-throws errors when calling @@matchAll
|
||||||
|
info: |
|
||||||
|
String.prototype.matchAll ( regexp )
|
||||||
|
[...]
|
||||||
|
2. If regexp is neither undefined nor null, then
|
||||||
|
a. Let matcher be ? GetMethod(regexp, @@matchAll).
|
||||||
|
b. If matcher is not undefined, then
|
||||||
|
i. Return ? Call(matcher, regexp, « O »).
|
||||||
|
features: [Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
RegExp.prototype[Symbol.matchAll] = function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
''.matchAll(/./);
|
||||||
|
});
|
22
test/built-ins/String/prototype/matchAll/this-val-non-obj-coercible.js
vendored
Normal file
22
test/built-ins/String/prototype/matchAll/this-val-non-obj-coercible.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2018 Jordan Harband. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: The `this` value cannot be coerced into an object
|
||||||
|
info: |
|
||||||
|
String.prototype.matchAll ( regexp )
|
||||||
|
1. Let O be RequireObjectCoercible(this value).
|
||||||
|
features: [String.prototype.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var matchAll = String.prototype.matchAll;
|
||||||
|
|
||||||
|
assert.sameValue(typeof matchAll, 'function');
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
matchAll.call(undefined);
|
||||||
|
}, 'undefined');
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
matchAll.call(null);
|
||||||
|
}, 'null');
|
14
test/built-ins/Symbol/matchAll/cross-realm.js
Normal file
14
test/built-ins/Symbol/matchAll/cross-realm.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: Value shared by all realms
|
||||||
|
info: |
|
||||||
|
Unless otherwise specified, well-known symbols values are shared by all
|
||||||
|
realms.
|
||||||
|
features: [cross-realm, Symbol.matchAll]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var OSymbol = $262.createRealm().global.Symbol;
|
||||||
|
|
||||||
|
assert.sameValue(Symbol.matchAll, OSymbol.matchAll);
|
17
test/built-ins/Symbol/matchAll/prop-desc.js
Normal file
17
test/built-ins/Symbol/matchAll/prop-desc.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (C) 2018 Peter Wong. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: pending
|
||||||
|
description: |
|
||||||
|
`Symbol.matchAll` property descriptor
|
||||||
|
info: |
|
||||||
|
This property has the attributes { [[Writable]]: false, [[Enumerable]]:
|
||||||
|
false, [[Configurable]]: false }.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Symbol.match]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(typeof Symbol.matchAll, 'symbol');
|
||||||
|
verifyNotEnumerable(Symbol, 'matchAll');
|
||||||
|
verifyNotWritable(Symbol, 'matchAll');
|
||||||
|
verifyNotConfigurable(Symbol, 'matchAll');
|
Loading…
x
Reference in New Issue
Block a user