Debian Codegraph @

js/src/tests/test262/built-ins/RegExp/named-groups/duplicate-names-matchall.js

raw
1 // |reftest| shell-option(--enable-regexp-duplicate-named-groups) skip-if(!xulRuntime.shell) -- requires shell-options
2 // Copyright 2022 Igalia S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 description: String.prototype.search behavior with duplicate named capture groups
7 esid: prod-GroupSpecifier
8 includes: [compareArray.js,compareIterator.js]
9 features: [regexp-duplicate-named-groups]
10 ---*/
11
12 function matchesIterator(iterator, expected) {
13 assert.compareIterator(iterator, expected.map(e => {
14 return v => assert.compareArray(v, e);
15 }));
16 }
17
18 matchesIterator("bab".matchAll(/(?<x>a)|(?<x>b)/g),
19 [
20 ["b", undefined, "b"],
21 ["a", "a", undefined],
22 ["b", undefined, "b"],
23 ]);
24 matchesIterator("bab".matchAll(/(?<x>b)|(?<x>a)/g),
25 [
26 ["b", "b", undefined],
27 ["a", undefined, "a"],
28 ["b", "b", undefined],
29 ]);
30
31 reportCompare(0, 0);