mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:27:43 +00:00
LibJS: Re-implement String.localeCompare using the StringCompare AO
This follows the ECMA402 spec and means String.prototype.localeCompare will automatically become actually locale aware once StringCompare is actually implemented based on UTS #10.
This commit is contained in:
parent
6558f4ae6b
commit
7ae2debf6e
2 changed files with 21 additions and 13 deletions
|
@ -9,7 +9,7 @@ test("basic functionality", () => {
|
|||
const aTob = a.localeCompare(b);
|
||||
const bToa = b.localeCompare(a);
|
||||
|
||||
expect(aTob).toBe(1);
|
||||
expect(aTob > 0).toBeTrue();
|
||||
expect(aTob).toBe(-bToa);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ test("basic functionality", () => {
|
|||
|
||||
expect("null".localeCompare(null)).toBe(0);
|
||||
expect("null".localeCompare(undefined)).not.toBe(0);
|
||||
expect("null".localeCompare()).toBe(-1);
|
||||
expect("null".localeCompare() < 0).toBeTrue();
|
||||
|
||||
expect(() => {
|
||||
String.prototype.localeCompare.call(undefined, undefined);
|
||||
|
@ -34,6 +34,6 @@ test("basic functionality", () => {
|
|||
test("UTF-16", () => {
|
||||
var s = "😀😀";
|
||||
expect(s.localeCompare("😀😀")).toBe(0);
|
||||
expect(s.localeCompare("\ud83d")).toBe(1);
|
||||
expect(s.localeCompare("😀😀s")).toBe(-1);
|
||||
expect(s.localeCompare("\ud83d") > 0);
|
||||
expect(s.localeCompare("😀😀s") < 0);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue