mirror of https://github.com/tc39/test262.git
Duplicate named capture groups: Syntax tests
Parse-time syntax for RegExp literals is already tested. These two files test runtime RegExp compilation, with respect to duplicate named capture groups. See: #3704
This commit is contained in:
parent
29f321a4e9
commit
d77d9b2b85
20
test/annexB/built-ins/RegExp/prototype/compile/duplicate-named-capturing-groups-syntax.js
vendored
Normal file
20
test/annexB/built-ins/RegExp/prototype/compile/duplicate-named-capturing-groups-syntax.js
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-regexp.prototype.compile
|
||||
description: Runtime parsing of syntax for duplicate named capturing groups
|
||||
features: [regexp-duplicate-named-groups]
|
||||
---*/
|
||||
|
||||
let r = /[ab]/;
|
||||
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => r.compile("(?<x>a)(?<x>b)"),
|
||||
"Duplicate named capturing groups in the same alternative do not parse"
|
||||
);
|
||||
|
||||
let source = "(?<x>a)|(?<x>b)";
|
||||
r.compile(source);
|
||||
assert.sameValue(r.source, source, "Duplicate named capturing groups in separate alternatives parse correctly");
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-regexp-pattern-flags
|
||||
description: Runtime parsing of syntax for duplicate named capturing groups
|
||||
features: [regexp-duplicate-named-groups]
|
||||
---*/
|
||||
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => new RegExp("(?<x>a)(?<x>b)"),
|
||||
"Duplicate named capturing groups in the same alternative do not parse"
|
||||
);
|
||||
|
||||
let source = "(?<x>a)|(?<x>b)";
|
||||
let parsed = new RegExp(source);
|
||||
assert.sameValue(parsed.source, source, "Duplicate named capturing groups in separate alternatives parse correctly");
|
Loading…
Reference in New Issue