mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:57:46 +00:00
LibJS: Add UTF-16 tests to String.prototype methods that already work
These methods did not require UTF-16 views, so just add test cases to ensure they remain correct. This also adds a couple of FIXME comments on tests that will fail even with UTF-16 String.prototype support (for reasons such as lack of UTF-16 support in RegExp.prototype and Unicode case folding).
This commit is contained in:
parent
9b83cd1abf
commit
0e25d2393f
6 changed files with 32 additions and 0 deletions
|
@ -15,3 +15,10 @@ test("basic functionality", () => {
|
|||
expect("".concat(1, {})).toBe("1[object Object]");
|
||||
expect("".concat(1, {}, false)).toBe("1[object Object]false");
|
||||
});
|
||||
|
||||
test("UTF-16", () => {
|
||||
expect("😀".concat()).toBe("😀");
|
||||
expect("😀".concat("a")).toBe("😀a");
|
||||
expect("😀".concat("a", 4)).toBe("😀a4");
|
||||
expect("😀".concat("a", "😀")).toBe("😀a😀");
|
||||
});
|
||||
|
|
|
@ -23,3 +23,9 @@ test("throws correct range errors", () => {
|
|||
"foo".repeat(Infinity);
|
||||
}).toThrowWithMessage(RangeError, "repeat count must be a finite number");
|
||||
});
|
||||
|
||||
test("UTF-16", () => {
|
||||
expect("😀".repeat(0)).toBe("");
|
||||
expect("😀".repeat(1)).toBe("😀");
|
||||
expect("😀".repeat(10)).toBe("😀😀😀😀😀😀😀😀😀😀");
|
||||
});
|
||||
|
|
|
@ -45,3 +45,11 @@ test("override exec with non-function", () => {
|
|||
re.exec = 3;
|
||||
expect("test".search(re)).toBe(0);
|
||||
});
|
||||
|
||||
// FIXME: RegExp.prototype [ @@search ] needs to support UTF-16.
|
||||
// test("UTF-16", () => {
|
||||
// var s = "😀";
|
||||
// expect(s.search("😀")).toBe(0);
|
||||
// expect(s.search("\ud83d")).toBe(0);
|
||||
// expect(s.search("\ude00")).toBe(1);
|
||||
// });
|
||||
|
|
|
@ -4,3 +4,8 @@ test("basic functionality", () => {
|
|||
expect("".toString()).toBe("");
|
||||
expect("hello friends".toString()).toBe("hello friends");
|
||||
});
|
||||
|
||||
test("UTF-16", () => {
|
||||
expect("😀".toString()).toBe("😀");
|
||||
expect("😀😀😀".toString()).toBe("😀😀😀");
|
||||
});
|
||||
|
|
|
@ -61,4 +61,8 @@ test("multi-byte code point", () => {
|
|||
expect("_\u180E".trim()).toBe("_\u180E");
|
||||
expect("\u180E".trim()).toBe("\u180E");
|
||||
expect("\u180E_".trim()).toBe("\u180E_");
|
||||
|
||||
expect("_😀".trim()).toBe("_😀");
|
||||
expect("😀".trim()).toBe("😀");
|
||||
expect("😀_".trim()).toBe("😀_");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue