mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:37:44 +00:00
LibJS: Implement String.prototype.substring with UTF-16 code units
This commit is contained in:
parent
767700d8a1
commit
60d8852fc2
2 changed files with 23 additions and 21 deletions
|
@ -12,3 +12,14 @@ test("basic functionality", () => {
|
|||
expect("hello friends".substring(0, "5")).toBe("hello");
|
||||
expect("hello friends".substring("6", "13")).toBe("friends");
|
||||
});
|
||||
|
||||
test("UTF-16", () => {
|
||||
var s = "😀";
|
||||
expect(s).toHaveLength(2);
|
||||
expect(s.substring()).toBe("😀");
|
||||
expect(s.substring(0)).toBe("😀");
|
||||
expect(s.substring(0, 2)).toBe("😀");
|
||||
expect(s.substring(0, 1)).toBe("\ud83d");
|
||||
expect(s.substring(1, 2)).toBe("\ude00");
|
||||
expect(s.substring(2, 2)).toBe("");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue