tor-browser

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

duplicate-names-replaceall.js (710B)


      1 // Copyright 2022 Igalia S.L. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: String.prototype.replaceAll behavior with duplicate named capture groups
      6 esid: prod-GroupSpecifier
      7 features: [regexp-duplicate-named-groups]
      8 ---*/
      9 
     10 assert.sameValue("abxab".replaceAll(/(?<x>a)|(?<x>b)/g, "[$<x>]"), "[a][b]x[a][b]");
     11 assert.sameValue("baxba".replaceAll(/(?<x>a)|(?<x>b)/g, "[$<x>]"), "[b][a]x[b][a]");
     12 
     13 assert.sameValue("abxab".replaceAll(/(?<x>a)|(?<x>b)/g, "[$<x>][$1][$2]"), "[a][a][][b][][b]x[a][a][][b][][b]");
     14 assert.sameValue("baxba".replaceAll(/(?<x>a)|(?<x>b)/g, "[$<x>][$1][$2]"), "[b][][b][a][a][]x[b][][b][a][a][]");
     15 
     16 
     17 reportCompare(0, 0);