mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-24 18:28:57 +00:00
LibJS: Implement String.prototype.substring with UTF-16 code units
This commit is contained in:
parent
767700d8a1
commit
60d8852fc2
Notes:
sideshowbarker
2024-07-18 08:35:49 +09:00
Author: https://github.com/trflynn89
Commit: 60d8852fc2
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 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