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
commit f920e121b3
Notes: sideshowbarker 2024-07-18 08:35:31 +09:00
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);
});