tor-browser

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

japanese-month-codes.js (2029B)


      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: PlainMonthDay can be created for all month codes (M01-M12) in Japanese calendar
      8 features: [Temporal, Intl.Era-monthcode]
      9 includes: [temporalHelpers.js]
     10 ---*/
     11 
     12 // Test that all month codes M01-M12 are valid for the Japanese calendar
     13 
     14 const calendar = "japanese";
     15 
     16 for (const { month, monthCode, daysInMonth } of TemporalHelpers.ISOMonths) {
     17  // Test creation with monthCode and day 1
     18  const pmd = Temporal.PlainMonthDay.from({ calendar, monthCode, day: 1 });
     19  TemporalHelpers.assertPlainMonthDay(pmd, monthCode, 1, `monthCode ${monthCode} should be preserved`);
     20 
     21  // Test creation with month and day 1
     22  const pmdMonth = Temporal.PlainMonthDay.from({ calendar, year: 1972, month, day: 1 });
     23  TemporalHelpers.assertPlainMonthDay(pmdMonth, monthCode, 1, `Equivalent monthCode ${monthCode} and month ${month} are resolved to the same PlainMonthDay`);
     24 
     25  // Test with maximum day value for this month (minimum for PlainMonthDay)
     26  const pmdMax = Temporal.PlainMonthDay.from({ calendar, monthCode, day: daysInMonth });
     27  TemporalHelpers.assertPlainMonthDay(pmdMax, monthCode, daysInMonth, `${monthCode} with day ${daysInMonth} should be valid`);
     28 
     29  // Test constrain overflow
     30  const constrained = Temporal.PlainMonthDay.from(
     31    { calendar, monthCode, day: daysInMonth + 1 },
     32    { overflow: "constrain" }
     33  );
     34  TemporalHelpers.assertPlainMonthDay(constrained, monthCode, daysInMonth, `day ${daysInMonth + 1} should be constrained to ${daysInMonth} for ${monthCode}`);
     35 
     36  // Test reject overflow
     37  assert.throws(RangeError, () => {
     38    Temporal.PlainMonthDay.from({ calendar, monthCode, day: daysInMonth + 1 }, { overflow: "reject" });
     39  }, `${monthCode} with day ${daysInMonth + 1} should throw with reject overflow`);
     40 }
     41 
     42 reportCompare(0, 0);