mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-19 07:49:05 +00:00
LibJS: Implement String.prototype.substr with UTF-16 code units
This commit is contained in:
parent
60d8852fc2
commit
892bfdbbcf
Notes:
sideshowbarker
2024-07-18 08:35:45 +09:00
Author: https://github.com/trflynn89
Commit: 892bfdbbcf
Pull-request: https://github.com/SerenityOS/serenity/pull/8897
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/davidot
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