Debian Codegraph @

js/src/tests/test262/built-ins/RegExp/named-groups/duplicate-names-group-property-enumeration-order.js

raw
1 // |reftest| shell-option(--enable-regexp-duplicate-named-groups) skip-if(!xulRuntime.shell) -- requires shell-options
2 // Copyright 2022 Kevin Gibbons. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 description: Enumeration order of the groups object with duplicate named capture groups
7 esid: prod-GroupSpecifier
8 features: [regexp-duplicate-named-groups]
9 includes: [compareArray.js]
10 ---*/
11
12
13 let regexp = /(?<y>a)(?<x>a)|(?<x>b)(?<y>b)/;
14
15 assert.compareArray(
16 Object.keys(regexp.exec("aa").groups),
17 ["y", "x"],
18 "property enumeration order of the groups object is based on source order, not match order"
19 );
20
21 assert.compareArray(
22 Object.keys(regexp.exec("bb").groups),
23 ["y", "x"],
24 "property enumeration order of the groups object is based on source order, not match order"
25 );
26
27 reportCompare(0, 0);