LibJS: Implement Temporal.Duration.prototype.sign/blank

This commit is contained in:
Timothy Flynn 2024-11-18 12:31:28 -05:00 committed by Tim Flynn
commit dfaa3bf649
Notes: github-actions[bot] 2024-11-21 00:06:14 +00:00
4 changed files with 66 additions and 0 deletions

View file

@ -0,0 +1,17 @@
describe("correct behavior", () => {
test("basic functionality", () => {
const nonBlankDuration = new Temporal.Duration(123);
expect(nonBlankDuration.blank).toBeFalse();
const blankDuration = new Temporal.Duration(0);
expect(blankDuration.blank).toBeTrue();
});
});
describe("errors", () => {
test("this value must be a Temporal.Duration object", () => {
expect(() => {
Reflect.get(Temporal.Duration.prototype, "blank", "foo");
}).toThrowWithMessage(TypeError, "Not an object of type Temporal.Duration");
});
});

View file

@ -0,0 +1,17 @@
describe("correct behavior", () => {
test("basic functionality", () => {
const positiveDuration = new Temporal.Duration(123);
expect(positiveDuration.sign).toBe(1);
const negativeDuration = new Temporal.Duration(-123);
expect(negativeDuration.sign).toBe(-1);
});
});
describe("errors", () => {
test("this value must be a Temporal.Duration object", () => {
expect(() => {
Reflect.get(Temporal.Duration.prototype, "sign", "foo");
}).toThrowWithMessage(TypeError, "Not an object of type Temporal.Duration");
});
});