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

LibJS: Implement RegExp.prototype [ @@search ] with UTF-16 code units

This commit is contained in:
Timothy Flynn 2021-07-22 10:22:07 -04:00 committed by Linus Groh
parent 2c023157e9
commit 66c31a0c07
3 changed files with 21 additions and 13 deletions

View file

@ -46,10 +46,15 @@ test("override exec with non-function", () => {
expect("test".search(re)).toBe(0);
});
// FIXME: RegExp.prototype [ @@search ] needs to support UTF-16.
// test("UTF-16", () => {
// var s = "😀";
// expect(s.search("😀")).toBe(0);
// expect(s.search("\ud83d")).toBe(0);
// expect(s.search("\ude00")).toBe(1);
// });
test("UTF-16", () => {
var s = "😀";
expect(s.search("😀")).toBe(0);
expect(s.search("\ud83d")).toBe(0);
expect(s.search("\ude00")).toBe(1);
expect(s.search("foo")).toBe(-1);
s = "\u{80}\u{160}";
expect(s.search("\u{80}")).toBe(0);
expect(s.search("\u{160}")).toBe(1);
expect(s.search("foo")).toBe(-1);
});