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

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

This commit is contained in:
Timothy Flynn 2021-07-19 11:13:39 -04:00 committed by Andreas Kling
parent 2bba20d123
commit 5d11614bc7
2 changed files with 24 additions and 4 deletions

View file

@ -18,3 +18,11 @@ test("basic functionality", () => {
expect(s.charAt("foo")).toBe("f");
expect(s.charAt(undefined)).toBe("f");
});
test("UTF-16", () => {
var s = "😀";
expect(s).toHaveLength(2);
expect(s.charAt(0)).toBe("\ud83d");
expect(s.charAt(1)).toBe("\ude00");
expect(s.charAt(2)).toBe("");
});