Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/RegExp/named-groups/groups-object.js

raw
1 // Copyright 2017 Aleksey Shvayka. 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 are created with CreateDataProperty
6 includes: [propertyHelper.js]
7 esid: sec-regexpbuiltinexec
8 features: [regexp-named-groups]
9 info: |
10 Runtime Semantics: RegExpBuiltinExec ( R, S )
11 24. If _R_ contains any |GroupName|, then
12 a. Let _groups_ be ObjectCreate(*null*).
13 25. Else,
14 a. Let _groups_ be *undefined*.
15 26. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
16 ---*/
17
18 // `groups` is created with Define, not Set.
19 let counter = 0;
20 Object.defineProperty(Array.prototype, "groups", {
21 set() { counter++; }
22 });
23
24 let match = /(?<x>.)/.exec("a");
25 assert.sameValue(counter, 0);
26
27 // `groups` is writable, enumerable and configurable
28 // (from CreateDataProperty).
29 verifyProperty(match, "groups", {
30 writable: true,
31 enumerable: true,
32 configurable: true,
33 });
34
35 // The `__proto__` property on the groups object is not special,
36 // and does not affect the [[Prototype]] of the resulting groups object.
37 let {groups} = /(?<__proto__>.)/.exec("a");
38 assert.sameValue("a", groups.__proto__);
39 assert.sameValue(null, Object.getPrototypeOf(groups));