Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainDateTime/compare/argument-plaindate.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.plaindatetime.compare
7 description: Fast path for converting Temporal.PlainDate to Temporal.PlainDateTime by reading internal slots
8 info: |
9 sec-temporal.plaindatetime.compare steps 1–2:
10 1. Set _one_ to ? ToTemporalDateTime(_one_).
11 2. Set _two_ to ? ToTemporalDateTime(_two_).
12 sec-temporal-totemporaldatetime step 2.b:
13 b. If _item_ has an [[InitializedTemporalDate]] internal slot, then
14 i. Return ? CreateTemporalDateTime(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], 0, 0, 0, 0, 0, 0, _item_.[[Calendar]]).
15 includes: [compareArray.js, temporalHelpers.js]
16 features: [Temporal]
17 ---*/
18
19 const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
20
21 TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => {
22 const result = Temporal.PlainDateTime.compare(date, datetime);
23 assert.sameValue(result, -1, "PlainDate is converted to midnight");
24 });
25
26 TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => {
27 const result = Temporal.PlainDateTime.compare(datetime, date);
28 assert.sameValue(result, 1, "PlainDate is converted to midnight");
29 });
30
31 reportCompare(0, 0);