Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/casts-arguments.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) 2022 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.zoneddatetime.compare
7 description: Casts first and second arguments.
8 features: [Temporal]
9 ---*/
10
11 /*
12 const zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23:30.123456789+01:00[+01:00]");
13 const zdt2 = Temporal.ZonedDateTime.from("2019-10-29T10:46:38.271986102+01:00[+01:00]");
14 */
15 const zdt1 = new Temporal.ZonedDateTime(217175010123456789n, "+01:00");
16 const zdt2 = new Temporal.ZonedDateTime(1572342398271986102n, "+01:00");
17
18 // casts first argument
19 assert.sameValue(Temporal.ZonedDateTime.compare({
20 year: 1976,
21 month: 11,
22 day: 18,
23 hour: 15,
24 timeZone: "+01:00"
25 }, zdt2), -1);
26 assert.sameValue(Temporal.ZonedDateTime.compare("1976-11-18T15:23:30.123456789+01:00[+01:00]", zdt2), -1);
27
28 // casts second argument
29 assert.sameValue(Temporal.ZonedDateTime.compare(zdt1, {
30 year: 2019,
31 month: 10,
32 day: 29,
33 hour: 10,
34 timeZone: "+01:00"
35 }), -1);
36 assert.sameValue(Temporal.ZonedDateTime.compare(zdt1, "2019-10-29T10:46:38.271986102+01:00[+01:00]"), -1);
37
38 reportCompare(0, 0);