tor-browser

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

argument-string-limits.js (1238B)


      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.plaindatetime.compare
      7 description: ISO strings at the edges of the representable range
      8 features: [Temporal]
      9 ---*/
     10 
     11 const instance = new Temporal.PlainDateTime(1976, 11, 18);
     12 
     13 const validStrings = [
     14  "-271821-04-19T00:00:00.000000001",
     15  "-271821-04-20",
     16  "+275760-09-13",
     17  "+275760-09-13T23:59:59.999999999",
     18 ];
     19 
     20 for (const arg of validStrings) {
     21  Temporal.PlainDateTime.compare(arg, instance);
     22  Temporal.PlainDateTime.compare(instance, arg);
     23 }
     24 
     25 const invalidStrings = [
     26  "-271821-04-19",
     27  "-271821-04-19T00:00",
     28  "+275760-09-14",
     29  "+275760-09-14T00:00",
     30 ];
     31 
     32 for (const arg of invalidStrings) {
     33  assert.throws(
     34    RangeError,
     35    () => Temporal.PlainDateTime.compare(arg, instance),
     36    `"${arg}" is outside the representable range of PlainDateTime (first argument)`
     37  );
     38  assert.throws(
     39    RangeError,
     40    () => Temporal.PlainDateTime.compare(instance, arg),
     41    `"${arg}" is outside the representable range of PlainDateTime (second argument)`
     42  );
     43 }
     44 
     45 reportCompare(0, 0);