Files
ladybird/Tests/LibJS/Runtime/regexp-unicode-zero-width-surrogate-positions.js
Andreas Kling 29c2fb9574 LibRegex: Keep empty-match surrogate candidates
Track whether a pattern can match empty and only skip interior
surrogate positions when the matcher must consume input. This keeps
the unicode candidate scan fast for consuming searches without
dropping valid zero-width matches such as /\B/ and /(?!...)/ between
a surrogate pair's two code units.

Add runtime coverage for both global lastIndex searches and plain
exec() searches on zero-width unicode patterns.
2026-03-27 17:32:19 +01:00

16 lines
485 B
JavaScript

test("unicode zero-width patterns can match at surrogate interior positions", () => {
let global_matcher = /\B/gu;
global_matcher.lastIndex = 2;
let match = global_matcher.exec("A😀");
expect(match).not.toBeNull();
expect(match[0]).toBe("");
expect(match.index).toBe(2);
expect(global_matcher.lastIndex).toBe(2);
match = /(?!😀)/u.exec("😀");
expect(match).not.toBeNull();
expect(match[0]).toBe("");
expect(match.index).toBe(1);
});