tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

infinity-throws-rangeerror.js (1155B)


      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.
      4 
      5 /*---
      6 description: Throws if any value in the property bag is Infinity or -Infinity
      7 esid: sec-temporal.plainmonthday.from
      8 includes: [compareArray.js, temporalHelpers.js]
      9 features: [Temporal]
     10 ---*/
     11 
     12 const base = { year: 2000, month: 5, day: 2 };
     13 
     14 [Infinity, -Infinity].forEach((inf) => {
     15  ["year", "month", "day"].forEach((prop) => {
     16    ["constrain", "reject"].forEach((overflow) => {
     17      assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ ...base, [prop]: inf }, { overflow }), `${prop} property cannot be ${inf} (overflow ${overflow}`);
     18 
     19      const calls = [];
     20      const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop);
     21      assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ ...base, [prop]: obj }, { overflow }));
     22      assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value");
     23    });
     24  });
     25 });
     26 
     27 reportCompare(0, 0);