tor-browser

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

indices-groups-object-unmatched.js (818B)


      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: Test the groups object of indices with matched and unmatched named captures.
      6 includes: [compareArray.js]
      7 esid: sec-makeindicesarray
      8 features: [regexp-named-groups, regexp-match-indices]
      9 info: |
     10  MakeIndicesArray ( S, indices, groupNames, hasGroups )
     11    11. For each integer _i_ such that _i_ >= 0 and _i_ < _n_, do
     12      e. If _i_ > 0 and _groupNames_[_i_ - 1] is not *undefined*, then
     13        i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_ - 1], _matchIndicesArray_).
     14 ---*/
     15 
     16 
     17 const re = /(?<a>a).|(?<x>x)/d;
     18 const result = re.exec("ab").indices;
     19 assert.compareArray([0, 1], result.groups.a);
     20 assert.sameValue(undefined, result.groups.x);
     21 
     22 reportCompare(0, 0);