mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibJS: Implement the Temporal.PlainDate constructor
And the simple Temporal.PlainDate.prototype getters, so that the constructed Temporal.PlainDate may actually be validated.
This commit is contained in:
parent
30fb2bf2e1
commit
a0c55f76e7
Notes:
github-actions[bot]
2024-11-23 13:48:20 +00:00
Author: https://github.com/trflynn89
Commit: a0c55f76e7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2513
Reviewed-by: https://github.com/shannonbooth ✅
30 changed files with 856 additions and 0 deletions
|
@ -0,0 +1,53 @@
|
|||
describe("errors", () => {
|
||||
test("called without new", () => {
|
||||
expect(() => {
|
||||
Temporal.PlainDate();
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"Temporal.PlainDate constructor must be called with 'new'"
|
||||
);
|
||||
});
|
||||
|
||||
test("cannot pass Infinity", () => {
|
||||
expect(() => {
|
||||
new Temporal.PlainDate(Infinity);
|
||||
}).toThrowWithMessage(RangeError, "Invalid plain date");
|
||||
expect(() => {
|
||||
new Temporal.PlainDate(0, Infinity);
|
||||
}).toThrowWithMessage(RangeError, "Invalid plain date");
|
||||
expect(() => {
|
||||
new Temporal.PlainDate(0, 0, Infinity);
|
||||
}).toThrowWithMessage(RangeError, "Invalid plain date");
|
||||
expect(() => {
|
||||
new Temporal.PlainDate(-Infinity);
|
||||
}).toThrowWithMessage(RangeError, "Invalid plain date");
|
||||
expect(() => {
|
||||
new Temporal.PlainDate(0, -Infinity);
|
||||
}).toThrowWithMessage(RangeError, "Invalid plain date");
|
||||
expect(() => {
|
||||
new Temporal.PlainDate(0, 0, -Infinity);
|
||||
}).toThrowWithMessage(RangeError, "Invalid plain date");
|
||||
});
|
||||
|
||||
test("cannot pass invalid ISO month/day", () => {
|
||||
expect(() => {
|
||||
new Temporal.PlainDate(0, 0, 1);
|
||||
}).toThrowWithMessage(RangeError, "Invalid plain date");
|
||||
expect(() => {
|
||||
new Temporal.PlainDate(0, 1, 0);
|
||||
}).toThrowWithMessage(RangeError, "Invalid plain date");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("length is 3", () => {
|
||||
expect(Temporal.PlainDate).toHaveLength(3);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const plainDate = new Temporal.PlainDate(2021, 7, 19);
|
||||
expect(typeof plainDate).toBe("object");
|
||||
expect(plainDate).toBeInstanceOf(Temporal.PlainDate);
|
||||
expect(Object.getPrototypeOf(plainDate)).toBe(Temporal.PlainDate.prototype);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue