tor-browser

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

leap-second.js (1349B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2022 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.from
      7 description: Leap second is a valid ISO string for PlainDateTime
      8 includes: [temporalHelpers.js]
      9 features: [Temporal]
     10 ---*/
     11 
     12 let arg = "2016-12-31T23:59:60";
     13 
     14 const result1 = Temporal.PlainDateTime.from(arg);
     15 TemporalHelpers.assertPlainDateTime(
     16  result1,
     17  2016, 12, "M12", 31, 23, 59, 59, 0, 0, 0,
     18  "leap second is a valid ISO string for PlainDateTime"
     19 );
     20 
     21 const result2 = Temporal.PlainDateTime.from(arg);
     22 TemporalHelpers.assertPlainDateTime(
     23  result2,
     24  2016, 12, "M12", 31, 23, 59, 59, 0, 0, 0,
     25  "leap second is a valid ISO string for PlainDateTime even with overflow: reject"
     26 );
     27 
     28 arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 };
     29 
     30 const result3 = Temporal.PlainDateTime.from(arg);
     31 TemporalHelpers.assertPlainDateTime(
     32  result3,
     33  2016, 12, "M12", 31, 23, 59, 59, 0, 0, 0,
     34  "second: 60 is constrained in property bag for PlainDateTime"
     35 );
     36 
     37 assert.throws(
     38  RangeError,
     39  () => Temporal.PlainDateTime.from(arg, { overflow: "reject" }),
     40  "second: 60 is rejected in property bag for PlainDateTime with overflow: reject"
     41 );
     42 
     43 reportCompare(0, 0);