Debian Codegraph @

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

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2021 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-temporal.instant.compare
7 description: Fast path for converting Temporal.ZonedDateTime to Temporal.Instant
8 info: |
9 sec-temporal.instant.compare steps 1–2:
10 1. Set _one_ to ? ToTemporalInstant(_one_).
11 2. Set _two_ to ? ToTemporalInstant(_two_).
12 sec-temporal-totemporalinstant step 1.b:
13 b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then
14 i. Return ! CreateTemporalInstant(_item_.[[Nanoseconds]]).
15 includes: [compareArray.js, temporalHelpers.js]
16 features: [Temporal]
17 ---*/
18
19 const instant = new Temporal.Instant(1_000_000_000_000_000_000n);
20
21 TemporalHelpers.checkToTemporalInstantFastPath((datetime) => {
22 const result = Temporal.Instant.compare(datetime, instant);
23 assert.sameValue(result, 1, "comparison result");
24 });
25
26 TemporalHelpers.checkToTemporalInstantFastPath((datetime) => {
27 const result = Temporal.Instant.compare(instant, datetime);
28 assert.sameValue(result, -1, "comparison result");
29 });
30
31 reportCompare(0, 0);