Debian Codegraph @

js/src/tests/test262/built-ins/RegExp/match-indices/indices-groups-properties.js

raw
1 // Copyright 2019 Ron Buckton. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: Properties of the groups object of indices are created with CreateDataProperty
6 includes: [compareArray.js, propertyHelper.js]
7 esid: sec-makeindicesarray
8 features: [regexp-named-groups, regexp-match-indices]
9 info: |
10 MakeIndicesArray ( S, indices, groupNames, hasIndices )
11 13. For each integer _i_ such that _i_ >= 0 and _i_ < _n_, do
12 e. If _i_ > 0 and _groupNames_[_i_ - 1] is not *undefined*, then
13 i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_ - 1], _matchIndicesArray_).
14 ---*/
15
16
17 // Properties created on result.groups in textual order.
18 let groupNames = Object.getOwnPropertyNames(/(?<fst>.)|(?<snd>.)/du.exec("abcd").indices.groups);
19 assert.compareArray(groupNames, ["fst", "snd"]);
20
21 // Properties are created with Define, not Set
22 let counter = 0;
23 Object.defineProperty(Object.prototype, 'x', {set() { counter++; }});
24
25 let indices = /(?<x>.)/d.exec('a').indices;
26 let groups = indices.groups;
27 assert.sameValue(counter, 0);
28
29 // Properties are writable, enumerable and configurable
30 // (from CreateDataProperty)
31 verifyProperty(groups, 'x', {
32 writable: true,
33 enumerable: true,
34 configurable: true
35 });
36
37 reportCompare(0, 0);