test262/test/built-ins/Temporal/Instant/compare/argument-zoneddatetime.js

29 lines
1.1 KiB
JavaScript
Raw 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");
});