tor-browser

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

infinity-throws-rangeerror.js (1694B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      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);