Debian Codegraph @

js/src/tests/test262/intl402/Temporal/PlainYearMonth/from/calendar-not-supporting-eras.js

raw symbols SCIP
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
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 resultHebrew = Temporal.PlainYearMonth.from({
30 era: "foobar",
31 eraYear: 1,
32 year: 5780,
33 monthCode: "M01",
34 calendar: "hebrew",
35 });
36 TemporalHelpers.assertPlainYearMonth(resultHebrew, 5780, 1, "M01",
37 "era and eraYear are ignored for calendar not using eras (Hebrew)",
38 undefined, undefined, 30);
39 assert.sameValue(resultHebrew.calendarId, "hebrew");
40
41 assert.throws(TypeError, () => Temporal.PlainYearMonth.from({
42 era: "foobar",
43 eraYear: 1,
44 monthCode: "M01",
45 day: 1,
46 calendar: "hebrew",
47 }), "era and eraYear cannot replace year for calendar not using eras (Hebrew)");
48
49 reportCompare(0, 0);