mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-15 14:02:20 +00:00
LibJS: Implement Temporal.Instant.prototype.epochMilliseconds
This commit is contained in:
parent
5010e01223
commit
b157ab3f12
Notes:
sideshowbarker
2024-07-18 10:02:39 +09:00
Author: https://github.com/linusg
Commit: b157ab3f12
Pull-request: https://github.com/SerenityOS/serenity/pull/8568
Reviewed-by: https://github.com/IdanHo
Reviewed-by: https://github.com/bgianfo ✅
4 changed files with 55 additions and 0 deletions
|
@ -0,0 +1,33 @@
|
|||
describe("correct behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
expect(new Temporal.Instant(0n).epochMilliseconds).toBe(0);
|
||||
expect(new Temporal.Instant(1n).epochMilliseconds).toBe(0);
|
||||
expect(new Temporal.Instant(999_999n).epochMilliseconds).toBe(0);
|
||||
expect(new Temporal.Instant(1_000_000n).epochMilliseconds).toBe(1);
|
||||
expect(new Temporal.Instant(1_500_000n).epochMilliseconds).toBe(1);
|
||||
expect(new Temporal.Instant(1_999_999n).epochMilliseconds).toBe(1);
|
||||
expect(new Temporal.Instant(2_000_000n).epochMilliseconds).toBe(2);
|
||||
expect(new Temporal.Instant(8_640_000_000_000_000_000_000n).epochMilliseconds).toBe(
|
||||
8_640_000_000_000_000
|
||||
);
|
||||
|
||||
expect(new Temporal.Instant(-0n).epochMilliseconds).toBe(0);
|
||||
expect(new Temporal.Instant(-1n).epochMilliseconds).toBe(0);
|
||||
expect(new Temporal.Instant(-999_999n).epochMilliseconds).toBe(0);
|
||||
expect(new Temporal.Instant(-1_000_000n).epochMilliseconds).toBe(-1);
|
||||
expect(new Temporal.Instant(-1_500_000n).epochMilliseconds).toBe(-1);
|
||||
expect(new Temporal.Instant(-1_999_999n).epochMilliseconds).toBe(-1);
|
||||
expect(new Temporal.Instant(-2_000_000n).epochMilliseconds).toBe(-2);
|
||||
expect(new Temporal.Instant(-8_640_000_000_000_000_000_000n).epochMilliseconds).toBe(
|
||||
-8_640_000_000_000_000
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("errors", () => {
|
||||
test("this value must be a Temporal.Instant object", () => {
|
||||
expect(() => {
|
||||
Reflect.get(Temporal.Instant.prototype, "epochMilliseconds", "foo");
|
||||
}).toThrowWithMessage(TypeError, "Not a Temporal.Instant");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue