Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/Duration/compare/relativeto-plaindate-add24hourdaystonormalizedtimeduration-out-of-range.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) 2024 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.duration.compare
7 description: RangeError thrown if adding the duration to the relativeTo date would result in anout-of-range date-time
8 features: [Temporal]
9 ---*/
10
11 let duration1 = Temporal.Duration.from({
12 years: 1,
13 seconds: 2**53 - 1,
14 });
15 let duration2 = Temporal.Duration.from({
16 years: 2,
17 });
18 let relativeTo = new Temporal.PlainDate(2000, 1, 1);
19
20 assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, { relativeTo }));
21 assert.throws(RangeError, () => Temporal.Duration.compare(duration2, duration1, { relativeTo }));
22
23 reportCompare(0, 0);