tor-browser

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

constrain-to-leap-day.js (1081B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2025 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.plainmonthday.from
      7 description: Properly constrain a day that is one past a leap day
      8 features: [Temporal]
      9 ---*/
     10 
     11 const tests = [
     12  ["buddhist", "M02", 30],
     13  ["chinese", "M01", 31],
     14  ["coptic", "M13", 7],
     15  ["dangi", "M01", 31],
     16  ["ethioaa", "M13", 7],
     17  ["ethiopic", "M13", 7],
     18  ["gregory", "M02", 30],
     19  ["hebrew", "M02", 31],
     20  ["indian", "M01", 32],
     21  ["islamic-civil", "M01", 31],
     22  ["islamic-tbla", "M01", 31],
     23  ["islamic-umalqura", "M01", 31],
     24  ["japanese", "M02", 30],
     25  ["persian", "M12", 31],
     26  ["roc", "M02", 30],
     27 ];
     28 
     29 for (const [calendar, monthCode, day] of tests) {
     30  const md = Temporal.PlainMonthDay.from({ calendar, monthCode, day }, { overflow: "constrain" });
     31  assert.sameValue(md.day, day - 1,
     32    `${calendar}: ${monthCode}-${day} should constrain to ${day - 1}, not ${day - 2}`)
     33 }
     34 
     35 reportCompare(0, 0);