tor-browser

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

argument-plaindate.js (1398B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2021 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: Fast path for converting Temporal.PlainDate to Temporal.PlainDateTime by reading internal slots
      8 info: |
      9    sec-temporal.plaindatetime.compare steps 1–2:
     10      1. Set _one_ to ? ToTemporalDateTime(_one_).
     11      2. Set _two_ to ? ToTemporalDateTime(_two_).
     12    sec-temporal-totemporaldatetime step 2.b:
     13      b. If _item_ has an [[InitializedTemporalDate]] internal slot, then
     14        i. Return ? CreateTemporalDateTime(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], 0, 0, 0, 0, 0, 0, _item_.[[Calendar]]).
     15 includes: [compareArray.js, temporalHelpers.js]
     16 features: [Temporal]
     17 ---*/
     18 
     19 const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
     20 
     21 TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => {
     22  const result = Temporal.PlainDateTime.compare(date, datetime);
     23  assert.sameValue(result, -1, "PlainDate is converted to midnight");
     24 });
     25 
     26 TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => {
     27  const result = Temporal.PlainDateTime.compare(datetime, date);
     28  assert.sameValue(result, 1, "PlainDate is converted to midnight");
     29 });
     30 
     31 reportCompare(0, 0);