| 1 |
// Copyright 2017 the V8 project authors. 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: [compareArray.js, propertyHelper.js] |
| 7 |
esid: sec-regexpbuiltinexec |
| 8 |
features: [regexp-named-groups] |
| 9 |
info: | |
| 10 |
Runtime Semantics: RegExpBuiltinExec ( R, S ) |
| 11 |
25. For each integer i such that i > 0 and i ≤ n |
| 12 |
f. If the ith capture of R was defined with a GroupName, |
| 13 |
i. Let s be the StringValue of the corresponding RegExpIdentifierName. |
| 14 |
ii. Perform ! CreateDataProperty(groups, s, capturedValue). |
| 15 |
---*/ |
| 16 |
|
| 17 |
// Properties created on result.groups in textual order. |
| 18 |
assert(compareArray(["fst", "snd"], |
| 19 |
Object.getOwnPropertyNames( |
| 20 |
/(?<fst>.)|(?<snd>.)/u.exec("abcd").groups))); |
| 21 |
|
| 22 |
// Properties are created with Define, not Set |
| 23 |
let counter = 0; |
| 24 |
Object.defineProperty(Object.prototype, 'x', {set() { counter++; }}); |
| 25 |
let match = /(?<x>.)/.exec('a'); |
| 26 |
let groups = match.groups; |
| 27 |
assert.sameValue(counter, 0); |
| 28 |
|
| 29 |
// Properties are writable, enumerable and configurable |
| 30 |
// (from CreateDataProperty) |
| 31 |
verifyWritable(groups, "x"); |
| 32 |
verifyEnumerable(groups, "x"); |
| 33 |
verifyConfigurable(groups, "x"); |