| 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.PlainYearMonth throws a RangeError if any numerical value is Infinity |
| 7 |
esid: sec-temporal.plainyearmonth |
| 8 |
includes: [compareArray.js, temporalHelpers.js] |
| 9 |
features: [Temporal] |
| 10 |
---*/ |
| 11 |
|
| 12 |
assert.throws(RangeError, () => new Temporal.PlainYearMonth(Infinity, 1)); |
| 13 |
assert.throws(RangeError, () => new Temporal.PlainYearMonth(1970, Infinity)); |
| 14 |
assert.throws(RangeError, () => new Temporal.PlainYearMonth(1970, 1, "iso8601", Infinity)); |
| 15 |
|
| 16 |
const O = (primitiveValue, propertyName) => (calls) => TemporalHelpers.toPrimitiveObserver(calls, primitiveValue, propertyName); |
| 17 |
const tests = [ |
| 18 |
[ |
| 19 |
"infinite year", |
| 20 |
[O(Infinity, "year"), O(1, "month"), () => "iso8601", O(1, "day")], |
| 21 |
["get year.valueOf", "call year.valueOf"] |
| 22 |
], |
| 23 |
[ |
| 24 |
"infinite month", |
| 25 |
[O(1970, "year"), O(Infinity, "month"), () => "iso8601", O(1, "day")], |
| 26 |
["get year.valueOf", "call year.valueOf", "get month.valueOf", "call month.valueOf"] |
| 27 |
], |
| 28 |
[ |
| 29 |
"infinite day", |
| 30 |
[O(1970, "year"), O(1, "month"), () => "iso8601", O(Infinity, "day")], |
| 31 |
["get year.valueOf", "call year.valueOf", "get month.valueOf", "call month.valueOf", "get day.valueOf", "call day.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.PlainYearMonth(...args_), description); |
| 39 |
assert.compareArray(actual, expected, `${description} order of operations`); |
| 40 |
} |
| 41 |
|
| 42 |
reportCompare(0, 0); |