Debian Codegraph @

js/src/tests/test262/built-ins/RegExp/duplicate-named-capturing-groups-syntax.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 esid: sec-regexp-pattern-flags
7 description: Runtime parsing of syntax for duplicate named capturing groups
8 features: [regexp-duplicate-named-groups]
9 ---*/
10
11 assert.throws(
12 SyntaxError,
13 () => new RegExp("(?<x>a)(?<x>b)"),
14 "Duplicate named capturing groups in the same alternative do not parse"
15 );
16
17 let source = "(?<x>a)|(?<x>b)";
18 let parsed = new RegExp(source);
19 assert.sameValue(parsed.source, source, "Duplicate named capturing groups in separate alternatives parse correctly");
20
21 reportCompare(0, 0);