Skip to content

Commit 70842e9

Browse files
committed
add some tests
1 parent 9a91e18 commit 70842e9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tests/tests/es.regexp.constructor.js

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ if (DESCRIPTORS) {
6969
assert.same(RegExp('(?<a>b)').exec('b').groups?.a, 'b', 'NCG #1');
7070
// eslint-disable-next-line regexp/no-unused-capturing-group -- required for testing
7171
assert.same(RegExp('(b)').exec('b').groups, undefined, 'NCG #2');
72+
const { groups } = RegExp('foo:(?<foo>\\w+),bar:(?<bar>\\w+)').exec('foo:abc,bar:def');
73+
assert.deepEqual(groups, { foo: 'abc', bar: 'def' }, 'NCG #3');
74+
assert.same(Object.getPrototypeOf(groups), null, 'NCG #4');
7275
assert.same('foo:abc,bar:def'.replace(RegExp('foo:(?<foo>\\w+),bar:(?<bar>\\w+)'), '$<bar>,$<foo>'), 'def,abc', 'replace #1');
7376
assert.same('foo:abc,bar:def'.replace(RegExp('foo:(?<foo>\\w+),bar:(?<bar>\\w+)'), (...args) => {
7477
const { foo, bar } = args.pop();

0 commit comments

Comments
 (0)