Files
sausage/userland/qjs/source/tests/bug1591.js
T
surma d44f1d9677 Build separate native and WASI pipelines with shared multicall names
Checkpoint before integration and package validation.

Assisted-by: SurmAgent:unknown [read] [edit] [bash]
2026-11-12 09:36:27 +00:00

27 lines
751 B
JavaScript

import { assert, assertThrows } from "./assert.js";
function pat(plain) {
return "(?<g>a)" + "|x".repeat(plain) + "|(?<g>c)";
}
function messageOf(re) {
try {
new RegExp(re);
} catch (e) {
return e.message;
}
return undefined;
}
// 256 alternatives: fine.
assert(new RegExp(pat(254)).test("a"), true);
// 257 alternatives and beyond: explicit error instead of a wrong
// "duplicate group name" report.
assert(messageOf(pat(255)), "too many named groups");
assert(messageOf(pat(1000)), "too many named groups");
// A genuine duplicate within the same alternative must still be rejected.
assert(messageOf("(?<g>a)(?<g>b)"), "duplicate group name");
assertThrows(SyntaxError, () => new RegExp("(?<g>a)(?<g>b)"));