mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:47:44 +00:00
LibJS: Implement String.prototype.replaceAll with UTF-16 code units
This commit is contained in:
parent
06208aaa15
commit
733a92820b
2 changed files with 33 additions and 12 deletions
|
@ -143,3 +143,15 @@ test("search value is coerced to a string", () => {
|
|||
expect(newString).toBe("abc");
|
||||
expect(coerced).toBe("x");
|
||||
});
|
||||
|
||||
test("UTF-16", () => {
|
||||
expect("😀".replaceAll("😀", "")).toBe("");
|
||||
expect("😀".replaceAll("\ud83d", "")).toBe("\ude00");
|
||||
expect("😀".replaceAll("\ude00", "")).toBe("\ud83d");
|
||||
expect("😀😀😀".replaceAll("\ud83d", "")).toBe("\ude00\ude00\ude00");
|
||||
expect("😀😀😀".replaceAll("\ude00", "")).toBe("\ud83d\ud83d\ud83d");
|
||||
|
||||
// FIXME: RegExp.prototype [ @@replace ] also needs to support UTF-16.
|
||||
// expect("😀".replaceAll(/\ud83d/g, "")).toBe("\ude00");
|
||||
// expect("😀".replaceAll(/\ude00/g, "")).toBe("\ud83d");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue