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

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

This commit is contained in:
Timothy Flynn 2021-07-19 15:29:20 -04:00 committed by Andreas Kling
parent 5ac964d841
commit f920e121b3
2 changed files with 40 additions and 21 deletions

View file

@ -20,3 +20,11 @@ test("basic functionality", () => {
expect("hello friends serenity".lastIndexOf("s", 13)).toBe(12);
expect("hello".lastIndexOf("serenity")).toBe(-1);
});
test("UTF-16", () => {
var s = "😀";
expect(s.lastIndexOf("😀")).toBe(0);
expect(s.lastIndexOf("\ud83d")).toBe(0);
expect(s.lastIndexOf("\ude00")).toBe(1);
expect(s.lastIndexOf("a")).toBe(-1);
});