indices-property.js 998 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2019 Ron Buckton. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. description: The "indices" property is created with DefinePropertyOrThrow
  5. includes: [propertyHelper.js]
  6. esid: sec-regexpbuiltinexec
  7. features: [regexp-match-indices]
  8. info: |
  9. Runtime Semantics: RegExpBuiltinExec ( R, S )
  10. 34. Let _indicesArray_ be MakeIndicesArray(_S_, _indices_, _groupNames_).
  11. 35. Perform ! DefinePropertyOrThrow(_A_, `"indices"`, PropertyDescriptor { [[Value]]: _indicesArray_, [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }).
  12. ---*/
  13. // `indices` is created with Define, not Set.
  14. let counter = 0;
  15. Object.defineProperty(Array.prototype, "indices", {
  16. set() { counter++; }
  17. });
  18. let match = /a/.exec("a");
  19. assert.sameValue(counter, 0);
  20. // `indices` is a non-writable, non-enumerable, and configurable data-property.
  21. verifyProperty(match, 'indices', {
  22. writable: true,
  23. enumerable: true,
  24. configurable: true
  25. });