Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainDate/compare/argument-string-limits.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.plaindate.compare
7 description: ISO strings at the edges of the representable range
8 features: [Temporal]
9 ---*/
10
11 const instance = new Temporal.PlainDate(1976, 11, 18);
12
13 const validStrings = [
14 "-271821-04-19",
15 "-271821-04-19T01:00",
16 "+275760-09-13",
17 "+275760-09-13T23:00",
18 ];
19
20 for (const arg of validStrings) {
21 Temporal.PlainDate.compare(arg, instance);
22 Temporal.PlainDate.compare(instance, arg);
23 }
24
25 const invalidStrings = [
26 "-271821-04-18",
27 "-271821-04-18T23:00",
28 "+275760-09-14",
29 "+275760-09-14T01:00",
30 ];
31
32 for (const arg of invalidStrings) {
33 assert.throws(
34 RangeError,
35 () => Temporal.PlainDate.compare(arg, instance),
36 `"${arg}" is outside the representable range of PlainDate (first argument)`
37 );
38 assert.throws(
39 RangeError,
40 () => Temporal.PlainDate.compare(instance, arg),
41 `"${arg}" is outside the representable range of PlainDate (second argument)`
42 );
43 }
44
45 reportCompare(0, 0);