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

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

This commit is contained in:
Timothy Flynn 2021-07-19 11:15:18 -04:00 committed by Andreas Kling
parent 5d11614bc7
commit 48a28a9a73
2 changed files with 15 additions and 4 deletions

View file

@ -19,3 +19,11 @@ test("basic functionality", () => {
expect(s.charCodeAt("foo")).toBe(70);
expect(s.charCodeAt(undefined)).toBe(70);
});
test("UTF-16", () => {
var s = "😀";
expect(s).toHaveLength(2);
expect(s.charCodeAt(0)).toBe(0xd83d);
expect(s.charCodeAt(1)).toBe(0xde00);
expect(s.charCodeAt(2)).toBe(NaN);
});