Fix invocations of some Temporal methods

We should make sure that we are providing the correct arguments to these
methods even if they are supposed to throw; they should throw for the
reason we expect, and not because we provided the wrong arguments.
This commit is contained in:
Philip Chimento 2022-04-15 13:36:47 -07:00 committed by Philip Chimento
parent c82e2782e6
commit 4fdb4ee52f
6 changed files with 6 additions and 6 deletions

View File

@ -55,7 +55,7 @@ const instance = new Temporal.Calendar("iso8601");
for (const arg of invalidStrings) {
assert.throws(
RangeError,
() => instance.dateAdd(arg),
() => instance.dateAdd(arg, new Temporal.Duration()),
`"${arg}" should not be a valid ISO string for a PlainDate`
);
}

View File

@ -15,7 +15,7 @@ const instance = new Temporal.Calendar("iso8601");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.dateAdd(arg),
() => instance.dateAdd(arg, new Temporal.Duration()),
"String with UTC designator should not be valid as a PlainDate"
);
});

View File

@ -12,6 +12,6 @@ const instance = new Temporal.Calendar("iso8601");
assert.throws(
RangeError,
() => { instance.dateAdd(arg); },
() => { instance.dateAdd(arg, new Temporal.Duration()); },
"reject minus zero as extended year"
);

View File

@ -55,7 +55,7 @@ const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
for (const arg of invalidStrings) {
assert.throws(
RangeError,
() => instance.toZonedDateTime({ plainDate: arg }),
() => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }),
`"${arg}" should not be a valid ISO string for a PlainDate`
);
}

View File

@ -15,7 +15,7 @@ const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.toZonedDateTime({ plainDate: arg }),
() => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }),
"String with UTC designator should not be valid as a PlainDate"
);
});

View File

@ -12,6 +12,6 @@ const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
assert.throws(
RangeError,
() => { instance.toZonedDateTime({ plainDate: arg }); },
() => { instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); },
"reject minus zero as extended year"
);