mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:57:35 +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:
parent
733a92820b
commit
d3c25593b9
2 changed files with 38 additions and 17 deletions
|
@ -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", ""]);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue