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

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

This commit is contained in:
Timothy Flynn 2021-07-19 13:46:21 -04:00 committed by Andreas Kling
parent 892bfdbbcf
commit ef2ff5f88b
2 changed files with 17 additions and 4 deletions

View file

@ -13,3 +13,11 @@ test("basic functionality", () => {
expect(string.at(-4)).toBeUndefined();
expect(string.at(-Infinity)).toBeUndefined();
});
test("UTF-16", () => {
var s = "😀";
expect(s).toHaveLength(2);
expect(s.at(0)).toBe("\ud83d");
expect(s.at(1)).toBe("\ude00");
expect(s.at(2)).toBeUndefined();
});