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

LibJS: Implement String.prototype.indexOf with UTF-16 code units

This commit is contained in:
Timothy Flynn 2021-07-19 12:54:48 -04:00 committed by Andreas Kling
parent 70f9c7e1c7
commit 767700d8a1
2 changed files with 23 additions and 8 deletions

View file

@ -21,3 +21,11 @@ test("basic functionality", () => {
expect(s.indexOf("e", 0)).toBe(1);
expect(s.indexOf("e", 2)).toBe(9);
});
test("UTF-16", () => {
var s = "😀";
expect(s.indexOf("😀")).toBe(0);
expect(s.indexOf("\ud83d")).toBe(0);
expect(s.indexOf("\ude00")).toBe(1);
expect(s.indexOf("a")).toBe(-1);
});