mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-30 14:20:21 +00:00
LibJS: Implement Intl.Locale.prototype.variants
This is a normative change in the ECMA-402 spec. See:
e8c995a
This commit is contained in:
parent
324bd0f163
commit
128675770c
Notes:
github-actions[bot]
2025-06-04 21:12:35 +00:00
Author: https://github.com/trflynn89
Commit: 128675770c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4996
7 changed files with 123 additions and 7 deletions
|
@ -0,0 +1,44 @@
|
|||
describe("errors", () => {
|
||||
test("called on non-Locale object", () => {
|
||||
expect(() => {
|
||||
Intl.Locale.prototype.variants;
|
||||
}).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
|
||||
});
|
||||
|
||||
test("duplicate variants", () => {
|
||||
expect(() => {
|
||||
new Intl.Locale("en-abcde-abcde");
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"en-abcde-abcde is not a structurally valid language tag"
|
||||
);
|
||||
|
||||
expect(() => {
|
||||
new Intl.Locale("en", { variants: "abcde-abcde" });
|
||||
}).toThrowWithMessage(RangeError, "abcde-abcde is not a valid value for option variants");
|
||||
});
|
||||
|
||||
test("invalid variant", () => {
|
||||
expect(() => {
|
||||
new Intl.Locale("en-a");
|
||||
}).toThrowWithMessage(RangeError, "en-a is not a structurally valid language tag");
|
||||
|
||||
expect(() => {
|
||||
new Intl.Locale("en", { variants: "a" });
|
||||
}).toThrowWithMessage(RangeError, "a is not a valid value for option variants");
|
||||
|
||||
expect(() => {
|
||||
new Intl.Locale("en", { variants: "-" });
|
||||
}).toThrowWithMessage(RangeError, "- is not a valid value for option variants");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
expect(new Intl.Locale("en").variants).toBeUndefined();
|
||||
expect(new Intl.Locale("en-abcde").variants).toBe("abcde");
|
||||
expect(new Intl.Locale("en-1234-abcde").variants).toBe("1234-abcde");
|
||||
expect(new Intl.Locale("en", { variants: "abcde" }).variants).toBe("abcde");
|
||||
expect(new Intl.Locale("en", { variants: "1234-abcde" }).variants).toBe("1234-abcde");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue