LibJS: Implement 'less than' for a String over code units

...Instead of code points.
This commit is contained in:
Shannon Booth 2025-05-15 17:58:28 +12:00 committed by Tim Flynn
commit 5495531118
Notes: github-actions[bot] 2025-05-17 12:01:57 +00:00
2 changed files with 22 additions and 25 deletions

View file

@ -40,3 +40,18 @@ test("properties", () => {
expect(Object.getOwnPropertyNames("abc")).toEqual(["0", "1", "2", "length"]);
expect(Object.getOwnPropertyNames("😀")).toEqual(["0", "1", "length"]);
});
test("less than", () => {
expect("a" < "").toBe(false);
expect("a" < "b").toBe(true);
expect("a" < "aa").toBe(true);
expect("aa" < "a").toBe(false);
expect("abc" < "abd").toBe(true);
expect("abc" < "abcd").toBe(true);
expect("😀" < "😁").toBe(true);
expect("" < "😁").toBe(true);
expect("😁" < "").toBe(false);
expect("a" < "A").toBe(false);
expect("a" < "a").toBe(false);
expect("" < "😀").toBe(false);
});