tor-browser

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

calendar-not-supporting-eras.js (1512B)


      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.plainyearmonth.from
      7 description: era and eraYear are ignored (for calendars not using eras)
      8 includes: [temporalHelpers.js]
      9 features: [Temporal]
     10 ---*/
     11 
     12 const result = Temporal.PlainYearMonth.from({
     13  era: "foobar",
     14  eraYear: 1,
     15  year: 1970,
     16  monthCode: "M01",
     17  calendar: "iso8601",
     18 });
     19 TemporalHelpers.assertPlainYearMonth(result, 1970, 1, "M01",
     20  "era and eraYear are ignored for calendar not using eras (iso8601)");
     21 
     22 assert.throws(TypeError, () => Temporal.PlainYearMonth.from({
     23  era: "foobar",
     24  eraYear: 1,
     25  monthCode: "M01",
     26  calendar: "iso8601",
     27 }), "era and eraYear cannot replace year for calendar not using eras (iso8601)");
     28 
     29 const resultChinese = Temporal.PlainYearMonth.from({
     30  era: "foobar",
     31  eraYear: 1,
     32  year: 2025,
     33  monthCode: "M01",
     34  calendar: "chinese",
     35 });
     36 TemporalHelpers.assertPlainYearMonth(resultChinese, 2025, 1, "M01",
     37  "era and eraYear are ignored for calendar not using eras (Chinese)",
     38  undefined, undefined, 29);
     39 assert.sameValue(resultChinese.calendarId, "chinese");
     40 
     41 assert.throws(TypeError, () => Temporal.PlainYearMonth.from({
     42  era: "foobar",
     43  eraYear: 1,
     44  monthCode: "M01",
     45  day: 1,
     46  calendar: "chinese",
     47 }), "era and eraYear cannot replace year for calendar not using eras (Chinese)");
     48 
     49 reportCompare(0, 0);