1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:27:35 +00:00

LibJS: Create the RegExpExec result's "input" field last

We move the input string into this field to avoid a string copy, so we
must do this step last to avoid using any views into it (note that
match.view here is a view into this string).
This commit is contained in:
Timothy Flynn 2021-11-07 18:49:04 -05:00 committed by Andreas Kling
parent 79fa9765ca
commit 2530b6adf0
2 changed files with 8 additions and 1 deletions

View file

@ -205,3 +205,10 @@ test("multiline stateful match", () => {
);
expect(res.index).toBe(231);
});
test("string coercion", () => {
let result = /1/.exec(1);
expect(result.length).toBe(1);
expect(result[0]).toBe("1");
expect(result.index).toBe(0);
});