tor-browser

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

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


      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.PlainDate throws a RangeError if any value is -Infinity
      7 esid: sec-temporal.plaindate
      8 includes: [compareArray.js, temporalHelpers.js]
      9 features: [Temporal]
     10 ---*/
     11 
     12 assert.throws(RangeError, () => new Temporal.PlainDate(-Infinity, 1, 1));
     13 assert.throws(RangeError, () => new Temporal.PlainDate(1970, -Infinity, 1));
     14 assert.throws(RangeError, () => new Temporal.PlainDate(1970, 1, -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"), O(1, "day")],
     21    ["get year.valueOf", "call year.valueOf"]
     22  ],
     23  [
     24    "infinite month",
     25    [O(2, "year"), O(-Infinity, "month"), O(1, "day")],
     26    ["get year.valueOf", "call year.valueOf", "get month.valueOf", "call month.valueOf"]
     27  ],
     28  [
     29    "infinite day",
     30    [O(2, "year"), O(1, "month"), 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.PlainDate(...args_), description);
     39  assert.compareArray(actual, expected, `${description} order of operations`);
     40 }
     41 
     42 reportCompare(0, 0);