Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / Temporal / Duration / from / argument-duration-max.js
blobaf9f721949b0f6515f693c9e14fa44571e32519a
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
2 // Copyright (C) 2023 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
5 /*---
6 esid: sec-temporal.duration.from
7 description: Maximum allowed duration
8 features: [Temporal]
9 ---*/
11 const maxCases = [
12   ["P4294967295Y104249991374DT7H36M31.999999999S", "string with max years"],
13   [{ years: 4294967295, days: 104249991374, nanoseconds: 27391999999999 }, "property bag with max years"],
14   ["P4294967295M104249991374DT7H36M31.999999999S", "string with max months"],
15   [{ months: 4294967295, days: 104249991374, nanoseconds: 27391999999999 }, "property bag with max months"],
16   ["P4294967295W104249991374DT7H36M31.999999999S", "string with max weeks"],
17   [{ weeks: 4294967295, days: 104249991374, nanoseconds: 27391999999999 }, "property bag with max weeks"],
18   ["P104249991374DT7H36M31.999999999S", "string with max days"],
19   [{ days: 104249991374, nanoseconds: 27391999999999 }, "property bag with max days"],
20   ["PT2501999792983H36M31.999999999S", "string with max hours"],
21   [{ hours: 2501999792983, nanoseconds: 2191999999999 }, "property bag with max hours"],
22   ["PT150119987579016M31.999999999S", "string with max minutes"],
23   [{ minutes: 150119987579016, nanoseconds: 31999999999 }, "property bag with max minutes"],
24   ["PT9007199254740991.999999999S", "string with max seconds"],
25   [{ seconds: 9007199254740991, nanoseconds: 999999999 }, "property bag with max seconds"],
28 for (const [arg, descr] of maxCases) {
29   const result = Temporal.Duration.from(arg);
30   assert.sameValue(result.with({ years: 0, months: 0, weeks: 0 }).total("seconds"), 9007199254740991.999999999, `operation succeeds with ${descr}`);
33 const minCases = [
34   ["-P4294967295Y104249991374DT7H36M31.999999999S", "string with min years"],
35   [{ years: -4294967295, days: -104249991374, nanoseconds: -27391999999999 }, "property bag with min years"],
36   ["-P4294967295M104249991374DT7H36M31.999999999S", "string with min months"],
37   [{ months: -4294967295, days: -104249991374, nanoseconds: -27391999999999 }, "property bag with min months"],
38   ["-P4294967295W104249991374DT7H36M31.999999999S", "string with min weeks"],
39   [{ weeks: -4294967295, days: -104249991374, nanoseconds: -27391999999999 }, "property bag with min weeks"],
40   ["-P104249991374DT7H36M31.999999999S", "string with min days"],
41   [{ days: -104249991374, nanoseconds: -27391999999999 }, "property bag with min days"],
42   ["-PT2501999792983H36M31.999999999S", "string with min hours"],
43   [{ hours: -2501999792983, nanoseconds: -2191999999999 }, "property bag with min hours"],
44   ["-PT150119987579016M31.999999999S", "string with min minutes"],
45   [{ minutes: -150119987579016, nanoseconds: -31999999999 }, "property bag with min minutes"],
46   ["-PT9007199254740991.999999999S", "string with min seconds"],
47   [{ seconds: -9007199254740991, nanoseconds: -999999999 }, "property bag with min seconds"],
50 for (const [arg, descr] of minCases) {
51   const result = Temporal.Duration.from(arg);
52   assert.sameValue(result.with({ years: 0, months: 0, weeks: 0 }).total("seconds"), -9007199254740991.999999999, `operation succeeds with ${descr}`);
55 reportCompare(0, 0);