Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainMonthDay/negative-infinity-throws-rangeerror.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) 2020 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 description: Temporal.PlainMonthDay throws a RangeError if any numerical value is -Infinity
7 esid: sec-temporal.plainmonthday
8 includes: [compareArray.js, temporalHelpers.js]
9 features: [Temporal]
10 ---*/
11
12 assert.throws(RangeError, () => new Temporal.PlainMonthDay(-Infinity, 1));
13 assert.throws(RangeError, () => new Temporal.PlainMonthDay(1, -Infinity));
14 assert.throws(RangeError, () => new Temporal.PlainMonthDay(1, 1, "iso8601", -Infinity));
15
16 const O = (primitiveValue, propertyName) => (calls) => TemporalHelpers.toPrimitiveObserver(calls, primitiveValue, propertyName);
17 const tests = [
18 [
19 "infinite month",
20 [O(-Infinity, "month"), O(1, "day"), () => "iso8601", O(1, "year")],
21 ["get month.valueOf", "call month.valueOf"]
22 ],
23 [
24 "infinite day",
25 [O(2, "month"), O(-Infinity, "day"), () => "iso8601", O(1, "year")],
26 ["get month.valueOf", "call month.valueOf", "get day.valueOf", "call day.valueOf"]
27 ],
28 [
29 "infinite year",
30 [O(2, "month"), O(1, "day"), () => "iso8601", O(-Infinity, "year")],
31 ["get month.valueOf", "call month.valueOf", "get day.valueOf", "call day.valueOf", "get year.valueOf", "call year.valueOf"]
32 ],
33 ];
34
35 for (const [description, args, expected] of tests) {
36 const actual = [];
37 const args_ = args.map((o) => o(actual));
38 assert.throws(RangeError, () => new Temporal.PlainMonthDay(...args_), description);
39 assert.compareArray(actual, expected, `${description} order of operations`);
40 }
41
42 reportCompare(0, 0);