mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:27:35 +00:00
LibRegex: Generate a 'Compare' op for empty character classes
Otherwise it would match zero-length strings. Fixes #6256.
This commit is contained in:
parent
7c98a6be17
commit
5a14f7ea2f
2 changed files with 15 additions and 0 deletions
|
@ -136,3 +136,15 @@ test("brace quantifier with invalid contents", () => {
|
|||
expect(res.length).toBe(1);
|
||||
expect(res[0]).toBe("{{lit-746579221856449}}");
|
||||
});
|
||||
|
||||
// #6256
|
||||
test("empty character class semantics", () => {
|
||||
// Should not match zero-length strings.
|
||||
let res = /[]/.exec("");
|
||||
expect(res).toBe(null);
|
||||
|
||||
// Inverse form, should match anything.
|
||||
res = /[^]/.exec("x");
|
||||
expect(res.length).toBe(1);
|
||||
expect(res[0]).toBe("x");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue