test262/test/built-ins/Temporal/Instant/compare/argument-zoneddatetime.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

29 lines
1.1 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.instant.compare
description: Fast path for converting Temporal.ZonedDateTime to Temporal.Instant
info: |
sec-temporal.instant.compare steps 12:
1. Set _one_ to ? ToTemporalInstant(_one_).
2. Set _two_ to ? ToTemporalInstant(_two_).
sec-temporal-totemporalinstant step 1.b:
b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then
i. Return ! CreateTemporalInstant(_item_.[[Nanoseconds]]).
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const instant = new Temporal.Instant(1_000_000_000_000_000_000n);
TemporalHelpers.checkToTemporalInstantFastPath((datetime) => {
const result = Temporal.Instant.compare(datetime, instant);
assert.sameValue(result, 1, "comparison result");
});
TemporalHelpers.checkToTemporalInstantFastPath((datetime) => {
const result = Temporal.Instant.compare(instant, datetime);
assert.sameValue(result, -1, "comparison result");
});