mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 01:59:31 +00:00
LibJS: Report string length as the code point length, not byte length
For example, U+180E is 3 bytes, but should have a string length of 1.
This commit is contained in:
parent
87848cdf7d
commit
a2e734d202
Notes:
sideshowbarker
2024-07-18 08:51:51 +09:00
Author: https://github.com/trflynn89
Commit: a2e734d202
Pull-request: https://github.com/SerenityOS/serenity/pull/8809
Reviewed-by: https://github.com/linusg
2 changed files with 9 additions and 1 deletions
|
@ -7,3 +7,10 @@ test("typeof", () => {
|
|||
expect(typeof String()).toBe("string");
|
||||
expect(typeof new String()).toBe("object");
|
||||
});
|
||||
|
||||
test("length", () => {
|
||||
expect(new String().length).toBe(0);
|
||||
expect(new String("a").length).toBe(1);
|
||||
expect(new String("\u180E").length).toBe(1);
|
||||
expect(new String("\uDBFF\uDFFF").length).toBe(2);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue