tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

duplicate-names-group-property-enumeration-order.js (740B)


      1 // Copyright 2022 Kevin Gibbons. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: Enumeration order of the groups object with duplicate named capture groups
      6 esid: prod-GroupSpecifier
      7 features: [regexp-duplicate-named-groups]
      8 includes: [compareArray.js]
      9 ---*/
     10 
     11 
     12 let regexp = /(?<y>a)(?<x>a)|(?<x>b)(?<y>b)/;
     13 
     14 assert.compareArray(
     15  Object.keys(regexp.exec("aa").groups),
     16  ["y", "x"],
     17  "property enumeration order of the groups object is based on source order, not match order"
     18 );
     19 
     20 assert.compareArray(
     21  Object.keys(regexp.exec("bb").groups),
     22  ["y", "x"],
     23  "property enumeration order of the groups object is based on source order, not match order"
     24 );
     25 
     26 reportCompare(0, 0);