Update tests which used negative day lengths

Negative day lengths are no longer valid after
<https://github.com/tc39/proposal-temporal/pull/2261>.
This commit is contained in:
André Bargull 2022-07-27 13:48:32 +02:00 committed by Philip Chimento
parent e623dd7a11
commit bea421c1dc
2 changed files with 6 additions and 8 deletions

View File

@ -9,7 +9,8 @@ info: |
Temporal.ZonedDateTime.prototype.round ( roundTo ) Temporal.ZonedDateTime.prototype.round ( roundTo )
... ...
18. Let dayLengthNs be (endNs - startNs). 18. Let dayLengthNs be (endNs - startNs).
... 19. If dayLengthNs 0, then
a. Throw a RangeError exception.
20. Let roundResult be ! RoundISODateTime(temporalDateTime.[[ISOYear]], 20. Let roundResult be ! RoundISODateTime(temporalDateTime.[[ISOYear]],
temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]],
temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]],
@ -74,12 +75,10 @@ const oneDay = 24n * 60n * 60n * 1000n * 1000n * 1000n
{ {
let tz = new TimeZone(minInstant); let tz = new TimeZone(minInstant);
let zoned = new Temporal.ZonedDateTime(0n, tz); let zoned = new Temporal.ZonedDateTime(0n, tz);
let result = zoned.round({ smallestUnit: "days" }); assert.throws(RangeError, () => zoned.round({ smallestUnit: "days" }));
assert(zoned.equals(result));
} }
{ {
let tz = new TimeZone(minInstant); let tz = new TimeZone(minInstant);
let zoned = new Temporal.ZonedDateTime(maxInstant - oneDay, tz); let zoned = new Temporal.ZonedDateTime(maxInstant - oneDay, tz);
let result = zoned.round({ smallestUnit: "days" }); assert.throws(RangeError, () => zoned.round({ smallestUnit: "days" }));
assert(zoned.equals(result));
} }

View File

@ -9,7 +9,7 @@ info: |
Temporal.ZonedDateTime.prototype.round ( roundTo ) Temporal.ZonedDateTime.prototype.round ( roundTo )
... ...
18. Let dayLengthNs be (endNs - startNs). 18. Let dayLengthNs be (endNs - startNs).
19. If dayLengthNs is 0, then 19. If dayLengthNs 0, then
a. Throw a RangeError exception. a. Throw a RangeError exception.
20. Let roundResult be ! RoundISODateTime(temporalDateTime.[[ISOYear]], 20. Let roundResult be ! RoundISODateTime(temporalDateTime.[[ISOYear]],
temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]],
@ -62,6 +62,5 @@ class TimeZone extends Temporal.TimeZone {
{ {
let tz = new TimeZone(-1n); let tz = new TimeZone(-1n);
let zoned = new Temporal.ZonedDateTime(0n, tz); let zoned = new Temporal.ZonedDateTime(0n, tz);
let result = zoned.round({ smallestUnit: "days" }); assert.throws(RangeError, () => zoned.round({ smallestUnit: "days" }));
assert(zoned.equals(result));
} }