1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
2 // Copyright (C) 2021 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
6 description: Throws if any value in a property bag for either argument is Infinity or -Infinity
7 esid: sec-temporal.plainyearmonth.compare
8 includes: [compareArray.js, temporalHelpers.js]
12 const other = new Temporal.PlainYearMonth(2000, 5, "gregory");
13 const base = { era: "ad", month: 5, calendar: "gregory" };
15 [Infinity, -Infinity].forEach((inf) => {
16 assert.throws(RangeError, () => Temporal.PlainYearMonth.compare({ ...base, eraYear: inf }, other), `eraYear property cannot be ${inf}`);
18 assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(other, { ...base, eraYear: inf }), `eraYear property cannot be ${inf}`);
21 const obj1 = TemporalHelpers.toPrimitiveObserver(calls1, inf, "eraYear");
22 assert.throws(RangeError, () => Temporal.PlainYearMonth.compare({ ...base, eraYear: obj1 }, other));
23 assert.compareArray(calls1, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value");
26 const obj2 = TemporalHelpers.toPrimitiveObserver(calls2, inf, "eraYear");
27 assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(other, { ...base, eraYear: obj2 }));
28 assert.compareArray(calls2, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value");