mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:17:45 +00:00
LibJS: Implement most Intl.Locale.Prototype.<<keyword>> properties
The keyword accessors all have the same function body in the spec, except for the Intl.Locale method they invoke. This generates those properties in the same manner as RegExp.prototype. Intl.Locale.prototype.calendar Intl.Locale.prototype.caseFirst Intl.Locale.prototype.collation Intl.Locale.prototype.hourCycle Intl.Locale.prototype.numberingSystem The exception is Intl.Locale.prototype.numeric, which will be defined separately because it is a boolean value.
This commit is contained in:
parent
21b3c5edba
commit
d7825f3680
7 changed files with 117 additions and 0 deletions
|
@ -0,0 +1,16 @@
|
|||
describe("errors", () => {
|
||||
test("called on non-Locale object", () => {
|
||||
expect(() => {
|
||||
Intl.Locale.prototype.calendar;
|
||||
}).toThrowWithMessage(TypeError, "Not a Intl.Locale object");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
expect(new Intl.Locale("en").calendar).toBeUndefined();
|
||||
expect(new Intl.Locale("en-u-ca-abc").calendar).toBe("abc");
|
||||
expect(new Intl.Locale("en", { calendar: "abc" }).calendar).toBe("abc");
|
||||
expect(new Intl.Locale("en-u-ca-abc", { calendar: "def" }).calendar).toBe("def");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
describe("errors", () => {
|
||||
test("called on non-Locale object", () => {
|
||||
expect(() => {
|
||||
Intl.Locale.prototype.caseFirst;
|
||||
}).toThrowWithMessage(TypeError, "Not a Intl.Locale object");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
expect(new Intl.Locale("en").caseFirst).toBeUndefined();
|
||||
expect(new Intl.Locale("en-u-kf-upper").caseFirst).toBe("upper");
|
||||
expect(new Intl.Locale("en", { caseFirst: "lower" }).caseFirst).toBe("lower");
|
||||
expect(new Intl.Locale("en-u-kf-upper", { caseFirst: "false" }).caseFirst).toBe("false");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
describe("errors", () => {
|
||||
test("called on non-Locale object", () => {
|
||||
expect(() => {
|
||||
Intl.Locale.prototype.collation;
|
||||
}).toThrowWithMessage(TypeError, "Not a Intl.Locale object");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
expect(new Intl.Locale("en").collation).toBeUndefined();
|
||||
expect(new Intl.Locale("en-u-co-abc").collation).toBe("abc");
|
||||
expect(new Intl.Locale("en", { collation: "abc" }).collation).toBe("abc");
|
||||
expect(new Intl.Locale("en-u-co-abc", { collation: "def" }).collation).toBe("def");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
describe("errors", () => {
|
||||
test("called on non-Locale object", () => {
|
||||
expect(() => {
|
||||
Intl.Locale.prototype.hourCycle;
|
||||
}).toThrowWithMessage(TypeError, "Not a Intl.Locale object");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
expect(new Intl.Locale("en").hourCycle).toBeUndefined();
|
||||
expect(new Intl.Locale("en-u-hc-h11").hourCycle).toBe("h11");
|
||||
expect(new Intl.Locale("en", { hourCycle: "h12" }).hourCycle).toBe("h12");
|
||||
expect(new Intl.Locale("en-u-hc-h23", { hourCycle: "h24" }).hourCycle).toBe("h24");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
describe("errors", () => {
|
||||
test("called on non-Locale object", () => {
|
||||
expect(() => {
|
||||
Intl.Locale.prototype.numberingSystem;
|
||||
}).toThrowWithMessage(TypeError, "Not a Intl.Locale object");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
expect(new Intl.Locale("en").numberingSystem).toBeUndefined();
|
||||
expect(new Intl.Locale("en-u-nu-abc").numberingSystem).toBe("abc");
|
||||
expect(new Intl.Locale("en", { numberingSystem: "abc" }).numberingSystem).toBe("abc");
|
||||
expect(new Intl.Locale("en-u-nu-abc", { numberingSystem: "def" }).numberingSystem).toBe(
|
||||
"def"
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue