duplicate-names-matchall.js (796B)
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.search behavior with duplicate named capture groups 6 esid: prod-GroupSpecifier 7 includes: [compareArray.js,compareIterator.js] 8 features: [regexp-duplicate-named-groups] 9 ---*/ 10 11 function matchesIterator(iterator, expected) { 12 assert.compareIterator(iterator, expected.map(e => { 13 return v => assert.compareArray(v, e); 14 })); 15 } 16 17 matchesIterator("bab".matchAll(/(?<x>a)|(?<x>b)/g), 18 [ 19 ["b", undefined, "b"], 20 ["a", "a", undefined], 21 ["b", undefined, "b"], 22 ]); 23 matchesIterator("bab".matchAll(/(?<x>b)|(?<x>a)/g), 24 [ 25 ["b", "b", undefined], 26 ["a", undefined, "a"], 27 ["b", "b", undefined], 28 ]); 29 30 reportCompare(0, 0);