Add missing `regexp-match-indices` feature tags (#2395)

This commit is contained in:
Mathias Bynens 2019-10-08 20:38:39 +02:00 committed by Leo Balter
parent 8688c4ab79
commit a898fe9826
4 changed files with 96 additions and 96 deletions

View File

@ -5,7 +5,7 @@
description: The groups object of indices is created unconditionally.
includes: [propertyHelper.js]
esid: sec-makeindicesarray
features: [regexp-named-groups]
features: [regexp-named-groups, regexp-match-indices]
info: |
MakeIndicesArray ( S, indices, groupNames )
8. If _groupNames_ is not *undefined*, then

View File

@ -1,20 +1,20 @@
// Copyright 2019 Ron Buckton. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Test the groups object of indices with matched and unmatched named captures.
includes: [compareArray.js]
esid: sec-makeindicesarray
features: [regexp-named-groups]
info: |
MakeIndicesArray ( S, indices, groupNames )
11. For each integer _i_ such that _i_ >= 0 and _i_ < _n_, do
e. If _groupNames_ is not *undfined* and _groupNames_[_i_] is not *undefined*, then
i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_], _matchIndicesArray_).
---*/
const re = /(?<a>a).|(?<x>x)/;
const result = re.exec("ab").indices;
assert.compareArray([0, 1], result.groups.a);
assert.sameValue(undefined, result.groups.x);
// Copyright 2019 Ron Buckton. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Test the groups object of indices with matched and unmatched named captures.
includes: [compareArray.js]
esid: sec-makeindicesarray
features: [regexp-named-groups, regexp-match-indices]
info: |
MakeIndicesArray ( S, indices, groupNames )
11. For each integer _i_ such that _i_ >= 0 and _i_ < _n_, do
e. If _groupNames_ is not *undfined* and _groupNames_[_i_] is not *undefined*, then
i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_], _matchIndicesArray_).
---*/
const re = /(?<a>a).|(?<x>x)/;
const result = re.exec("ab").indices;
assert.compareArray([0, 1], result.groups.a);
assert.sameValue(undefined, result.groups.x);

View File

@ -1,40 +1,40 @@
// Copyright 2019 Ron Buckton. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: The groups object of indices is created with CreateDataProperty
includes: [compareArray.js, propertyHelper.js]
esid: sec-makeindicesarray
features: [regexp-named-groups]
info: |
MakeIndicesArray ( S, indices, groupNames )
8. If _groupNames_ is not *undefined*, then
a. Let _groups_ be ! ObjectCreate(*null*).
9. Else,
a. Let _groups_ be *undefined*.
10. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
---*/
// `groups` is created with Define, not Set.
let counter = 0;
Object.defineProperty(Array.prototype, "groups", {
set() { counter++; }
});
let indices = /(?<x>.)/.exec("a").indices;
assert.sameValue(counter, 0);
// `groups` is writable, enumerable and configurable
// (from CreateDataProperty).
verifyProperty(indices, 'groups', {
writable: true,
enumerable: true,
configurable: true
});
// The `__proto__` property on the groups object is not special,
// and does not affect the [[Prototype]] of the resulting groups object.
let {groups} = /(?<__proto__>.)/.exec("a").indices;
assert.compareArray([0, 1], groups.__proto__);
assert.sameValue(null, Object.getPrototypeOf(groups));
// Copyright 2019 Ron Buckton. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: The groups object of indices is created with CreateDataProperty
includes: [compareArray.js, propertyHelper.js]
esid: sec-makeindicesarray
features: [regexp-named-groups, regexp-match-indices]
info: |
MakeIndicesArray ( S, indices, groupNames )
8. If _groupNames_ is not *undefined*, then
a. Let _groups_ be ! ObjectCreate(*null*).
9. Else,
a. Let _groups_ be *undefined*.
10. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
---*/
// `groups` is created with Define, not Set.
let counter = 0;
Object.defineProperty(Array.prototype, "groups", {
set() { counter++; }
});
let indices = /(?<x>.)/.exec("a").indices;
assert.sameValue(counter, 0);
// `groups` is writable, enumerable and configurable
// (from CreateDataProperty).
verifyProperty(indices, 'groups', {
writable: true,
enumerable: true,
configurable: true
});
// The `__proto__` property on the groups object is not special,
// and does not affect the [[Prototype]] of the resulting groups object.
let {groups} = /(?<__proto__>.)/.exec("a").indices;
assert.compareArray([0, 1], groups.__proto__);
assert.sameValue(null, Object.getPrototypeOf(groups));

View File

@ -1,35 +1,35 @@
// Copyright 2019 Ron Buckton. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Properties of the groups object of indices are created with CreateDataProperty
includes: [compareArray.js, propertyHelper.js]
esid: sec-makeindicesarray
features: [regexp-named-groups]
info: |
MakeIndicesArray ( S, indices, groupNames )
11. For each integer _i_ such that _i_ >= 0 and _i_ < _n_, do
e. If _groupNames_ is not *undfined* and _groupNames_[_i_] is not *undefined*, then
i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_], _matchIndicesArray_).
---*/
// Properties created on result.groups in textual order.
let groupNames = Object.getOwnPropertyNames(/(?<fst>.)|(?<snd>.)/u.exec("abcd").indices.groups);
assert.compareArray(groupNames, ["fst", "snd"]);
// // Properties are created with Define, not Set
// let counter = 0;
// Object.defineProperty(Object.prototype, 'x', {set() { counter++; }});
let indices = /(?<x>.)/.exec('a').indices;
let groups = indices.groups;
// assert.sameValue(counter, 0);
// Properties are writable, enumerable and configurable
// (from CreateDataProperty)
verifyProperty(groups, 'x', {
writable: true,
enumerable: true,
configurable: true
});
// Copyright 2019 Ron Buckton. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Properties of the groups object of indices are created with CreateDataProperty
includes: [compareArray.js, propertyHelper.js]
esid: sec-makeindicesarray
features: [regexp-named-groups, regexp-match-indices]
info: |
MakeIndicesArray ( S, indices, groupNames )
11. For each integer _i_ such that _i_ >= 0 and _i_ < _n_, do
e. If _groupNames_ is not *undfined* and _groupNames_[_i_] is not *undefined*, then
i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_], _matchIndicesArray_).
---*/
// Properties created on result.groups in textual order.
let groupNames = Object.getOwnPropertyNames(/(?<fst>.)|(?<snd>.)/u.exec("abcd").indices.groups);
assert.compareArray(groupNames, ["fst", "snd"]);
// // Properties are created with Define, not Set
// let counter = 0;
// Object.defineProperty(Object.prototype, 'x', {set() { counter++; }});
let indices = /(?<x>.)/.exec('a').indices;
let groups = indices.groups;
// assert.sameValue(counter, 0);
// Properties are writable, enumerable and configurable
// (from CreateDataProperty)
verifyProperty(groups, 'x', {
writable: true,
enumerable: true,
configurable: true
});