1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:57:35 +00:00

LibJS: Implement Temporal.Instant.prototype.epochNanoseconds

This commit is contained in:
Linus Groh 2021-07-08 22:20:49 +01:00
parent b5d0cdc97e
commit 117323f2d9
4 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,25 @@
describe("correct behavior", () => {
test("basic functionality", () => {
expect(new Temporal.Instant(0n).epochNanoseconds).toBe(0n);
expect(new Temporal.Instant(1n).epochNanoseconds).toBe(1n);
expect(new Temporal.Instant(999n).epochNanoseconds).toBe(999n);
expect(new Temporal.Instant(8_640_000_000_000_000_000_000n).epochNanoseconds).toBe(
8_640_000_000_000_000_000_000n
);
expect(new Temporal.Instant(-0n).epochNanoseconds).toBe(-0n);
expect(new Temporal.Instant(-1n).epochNanoseconds).toBe(-1n);
expect(new Temporal.Instant(-999n).epochNanoseconds).toBe(-999n);
expect(new Temporal.Instant(-8_640_000_000_000_000_000_000n).epochNanoseconds).toBe(
-8_640_000_000_000_000_000_000n
);
});
});
test("errors", () => {
test("this value must be a Temporal.Instant object", () => {
expect(() => {
Reflect.get(Temporal.Instant.prototype, "epochNanoseconds", "foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.Instant");
});
});