2019-10-08 20:38:39 +02:00
|
|
|
// 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: |
|
2021-01-15 08:06:42 +01:00
|
|
|
MakeIndicesArray ( S, indices, groupNames, hasIndices )
|
|
|
|
13. For each integer _i_ such that _i_ >= 0 and _i_ < _n_, do
|
|
|
|
e. If _i_ > 0 and _groupNames_[_i_ - 1] is not *undefined*, then
|
|
|
|
i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_ - 1], _matchIndicesArray_).
|
2019-10-08 20:38:39 +02:00
|
|
|
---*/
|
|
|
|
|
|
|
|
|
|
|
|
// Properties created on result.groups in textual order.
|
2021-01-15 08:06:42 +01:00
|
|
|
let groupNames = Object.getOwnPropertyNames(/(?<fst>.)|(?<snd>.)/du.exec("abcd").indices.groups);
|
2019-10-08 20:38:39 +02:00
|
|
|
assert.compareArray(groupNames, ["fst", "snd"]);
|
|
|
|
|
2021-02-21 01:02:49 +01:00
|
|
|
// Properties are created with Define, not Set
|
|
|
|
let counter = 0;
|
|
|
|
Object.defineProperty(Object.prototype, 'x', {set() { counter++; }});
|
2019-10-08 20:38:39 +02:00
|
|
|
|
2021-01-15 08:06:42 +01:00
|
|
|
let indices = /(?<x>.)/d.exec('a').indices;
|
2019-10-08 20:38:39 +02:00
|
|
|
let groups = indices.groups;
|
2021-02-21 01:02:49 +01:00
|
|
|
assert.sameValue(counter, 0);
|
2019-10-08 20:38:39 +02:00
|
|
|
|
|
|
|
// Properties are writable, enumerable and configurable
|
|
|
|
// (from CreateDataProperty)
|
|
|
|
verifyProperty(groups, 'x', {
|
|
|
|
writable: true,
|
|
|
|
enumerable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|