Expand Duration.compare test

This adds coverage for the situation where we get a different answer from
Temporal.Duration.compare depending on whether relativeTo resolves to a
PlainDate or ZonedDateTime.

See discussion in
https://github.com/tc39/test262/pull/3505#discussion_r859994610
This commit is contained in:
Philip Chimento 2022-04-29 16:30:23 -07:00 committed by Ms2ger
parent 65a7ace1cb
commit 8e0e2592d3
1 changed files with 17 additions and 0 deletions

View File

@ -4,6 +4,7 @@
/*---
esid: sec-temporal.duration.compare
description: relativeTo with hours.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
@ -22,3 +23,19 @@ assert.sameValue(Temporal.Duration.compare(oneDay, hours24, { relativeTo: "2019-
assert.sameValue(Temporal.Duration.compare(oneDay, hours24, { relativeTo: { year: 2019, month: 11, day: 3 } }),
0,
"casts relativeTo to PlainDate from object");
const timeZone = TemporalHelpers.springForwardFallBackTimeZone();
assert.sameValue(
Temporal.Duration.compare(oneDay, hours24, { relativeTo: new Temporal.ZonedDateTime(0n, timeZone) }),
0,
'relativeTo does not affect days if ZonedDateTime, and duration encompasses no DST change');
assert.sameValue(
Temporal.Duration.compare(oneDay, hours24, { relativeTo: new Temporal.ZonedDateTime(972802800_000_000_000n, timeZone) }),
1,
'relativeTo does affect days if ZonedDateTime, and duration encompasses DST change');
assert.sameValue(
Temporal.Duration.compare(oneDay, hours24, {
relativeTo: { year: 2000, month: 10, day: 29, timeZone }
}),
1,
'casts relativeTo to ZonedDateTime from object');