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