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

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

Also required implementing the SplitMatch abstract operation with UTF-16
code units.
This commit is contained in:
Timothy Flynn 2021-07-19 17:21:58 -04:00 committed by Andreas Kling
parent 733a92820b
commit d3c25593b9
2 changed files with 38 additions and 17 deletions

View file

@ -65,3 +65,15 @@ test("regex split", () => {
"",
]);
});
test("UTF-16", () => {
var s = "😀";
expect(s.split()).toEqual(["😀"]);
expect(s.split("😀")).toEqual(["", ""]);
expect(s.split("\ud83d")).toEqual(["", "\ude00"]);
expect(s.split("\ude00")).toEqual(["\ud83d", ""]);
// FIXME: RegExp.prototype [ @@split ] also needs to support UTF-16.
// expect(s.split(/\ud83d/)).toEqual(["", "\ude00"]);
// expect(s.split(/\ude00/)).toEqual(["\ud83d", ""]);
});