Debian Codegraph @

js/src/tests/test262/built-ins/RegExp/named-groups/duplicate-names-test.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: Matching behavior with duplicate named capture groups
7 esid: prod-GroupSpecifier
8 features: [regexp-duplicate-named-groups]
9 ---*/
10
11 assert(/(?<x>a)|(?<x>b)/.test("bab"));
12 assert(/(?<x>b)|(?<x>a)/.test("bab"));
13
14 assert(/(?:(?<x>a)|(?<x>b))\k<x>/.test("aa"));
15 assert(/(?:(?<x>a)|(?<x>b))\k<x>/.test("bb"));
16
17 let matchResult = /(?:(?:(?<x>a)|(?<x>b))\k<x>){2}/.test("aabb");
18 assert(matchResult);
19
20 let notMatched = /(?:(?:(?<x>a)|(?<x>b))\k<x>){2}/.test("abab");
21 assert.sameValue(notMatched, false);
22
23 reportCompare(0, 0);