indices-property.js (1069B)
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: The "indices" property is created with DefinePropertyOrThrow 6 includes: [propertyHelper.js] 7 esid: sec-regexpbuiltinexec 8 features: [regexp-match-indices] 9 info: | 10 Runtime Semantics: RegExpBuiltinExec ( R, S ) 11 8. If _flags_ contains `"d"`, let _hasIndices_ be *true*, else let _hasIndices_ be *false*. 12 ... 13 36. If _hasIndices_ is *true*, then 14 a. Let _indicesArray_ be MakeIndicesArray(_S_, _indices_, _groupNames_, _hasGroups_). 15 b. Perform ! CreateDataProperty(_A_, `"indices"`, _indicesArray_). 16 ---*/ 17 18 // `indices` is created with Define, not Set. 19 let counter = 0; 20 Object.defineProperty(Array.prototype, "indices", { 21 set() { counter++; } 22 }); 23 24 let match = /a/d.exec("a"); 25 assert.sameValue(counter, 0); 26 27 // `indices` is a non-writable, non-enumerable, and configurable data-property. 28 verifyProperty(match, 'indices', { 29 writable: true, 30 enumerable: true, 31 configurable: true 32 }); 33 34 reportCompare(0, 0);