groups-properties.js (1255B)
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"], Object.getOwnPropertyNames( 19 /(?<fst>.)|(?<snd>.)/u.exec("abcd").groups)); 20 21 // Properties are created with Define, not Set 22 let counter = 0; 23 Object.defineProperty(Object.prototype, 'x', {set() { counter++; }}); 24 let match = /(?<x>.)/.exec('a'); 25 let groups = match.groups; 26 assert.sameValue(counter, 0); 27 28 // Properties are writable, enumerable and configurable 29 // (from CreateDataProperty) 30 verifyProperty(groups, "x", { 31 writable: true, 32 enumerable: true, 33 configurable: true, 34 }); 35 36 reportCompare(0, 0);