tor-browser

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

argument-string-limits.js (1289B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2024 Igalia, S.L. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-temporal.plainyearmonth.compare
      7 description: ISO strings at the edges of the representable range
      8 features: [Temporal]
      9 ---*/
     10 
     11 const instance = new Temporal.PlainYearMonth(2019, 6);
     12 
     13 const validStrings = [
     14  "-271821-04",
     15  "-271821-04-01",
     16  "-271821-04-01T00:00",
     17  "+275760-09",
     18  "+275760-09-30",
     19  "+275760-09-30T23:59:59.999999999",
     20 ];
     21 
     22 for (const arg of validStrings) {
     23  Temporal.PlainYearMonth.compare(arg, instance);
     24  Temporal.PlainYearMonth.compare(instance, arg);
     25 }
     26 
     27 const invalidStrings = [
     28  "-271821-03-31",
     29  "-271821-03-31T23:59:59.999999999",
     30  "+275760-10",
     31  "+275760-10-01",
     32  "+275760-10-01T00:00",
     33 ];
     34 
     35 for (const arg of invalidStrings) {
     36  assert.throws(
     37    RangeError,
     38    () => Temporal.PlainYearMonth.compare(arg, instance),
     39    `"${arg}" is outside the representable range of PlainYearMonth (first argument)`
     40  );
     41  assert.throws(
     42    RangeError,
     43    () => Temporal.PlainYearMonth.compare(instance, arg),
     44    `"${arg}" is outside the representable range of PlainYearMonth (second argument)`
     45  );
     46 }
     47 
     48 reportCompare(0, 0);