tor-browser

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

negative-infinity-throws-rangeerror.js (1720B)


      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.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 
     13 assert.throws(RangeError, () => new Temporal.PlainYearMonth(-Infinity, 1));
     14 assert.throws(RangeError, () => new Temporal.PlainYearMonth(1970, -Infinity));
     15 assert.throws(RangeError, () => new Temporal.PlainYearMonth(1970, 1, "iso8601", -Infinity));
     16 
     17 const O = (primitiveValue, propertyName) => (calls) => TemporalHelpers.toPrimitiveObserver(calls, primitiveValue, propertyName);
     18 const tests = [
     19  [
     20    "infinite year",
     21    [O(-Infinity, "year"), O(1, "month"), () => "iso8601", O(1, "day")],
     22    ["get year.valueOf", "call year.valueOf"]
     23  ],
     24  [
     25    "infinite month",
     26    [O(1970, "year"), O(-Infinity, "month"), () => "iso8601", O(1, "day")],
     27    ["get year.valueOf", "call year.valueOf", "get month.valueOf", "call month.valueOf"]
     28  ],
     29  [
     30    "infinite day",
     31    [O(1970, "year"), O(1, "month"), () => "iso8601", O(-Infinity, "day")],
     32    ["get year.valueOf", "call year.valueOf", "get month.valueOf", "call month.valueOf", "get day.valueOf", "call day.valueOf"]
     33  ],
     34 ];
     35 
     36 for (const [description, args, expected] of tests) {
     37  const actual = [];
     38  const args_ = args.map((o) => o(actual));
     39  assert.throws(RangeError, () => new Temporal.PlainYearMonth(...args_), description);
     40  assert.compareArray(actual, expected, `${description} order of operations`);
     41 }
     42 
     43 reportCompare(0, 0);