test262/test/built-ins/Temporal/ZonedDateTime/compare/timezone-getpossibleinstantsfor-iterable.js
Philip Chimento 77a34cf93f Add Temporal tests
This copies over the tests that previously existed in the
tc39/proposal-temporal repository.

For context, see thread starting at:
https://github.com/tc39/test262/issues/3002#issuecomment-926234480

In service of https://github.com/tc39/test262/issues/3002
2021-10-01 14:30:12 -04:00

44 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.compare
description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call
info: |
sec-temporal.zoneddatetime.compare steps 12:
1. Set _one_ to ? ToTemporalZonedDateTime(_one_).
2. Set _two_ to ? ToTemporalZonedDateTime(_two_).
sec-temporal-totemporalzoneddatetime step 7:
7. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_result_.[[Year]], [...], _result_.[[Nanosecond]], _offsetNanoseconds_, _timeZone_, _disambiguation_, _offset_).
sec-temporal-interpretisodatetimeoffset step 7:
7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_).
sec-temporal-getpossibleinstantsfor step 2:
2. Let _list_ be ? IterableToList(_possibleInstants_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const expected1 = [
"2000-05-02T00:00:00",
];
TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => {
Temporal.ZonedDateTime.compare(
{ year: 2000, month: 5, day: 2, timeZone },
{ year: 2001, month: 6, day: 3, timeZone: "UTC" },
);
}, expected1);
// Same, but on the other operand
const expected2 = [
"2001-06-03T00:00:00",
];
TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => {
Temporal.ZonedDateTime.compare(
{ year: 2000, month: 5, day: 2, timeZone: "UTC" },
{ year: 2001, month: 6, day: 3, timeZone },
);
}, expected2);