Debian Codegraph @

js/src/tests/test262/intl402/Temporal/PlainMonthDay/from/fields-object.js

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2023 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: Basic tests for PlainMonthDay.from(object) with non-ISO calendar
8 includes: [temporalHelpers.js]
9 features: [Temporal]
10 ---*/
11
12 const okTests = [
13 [{ monthCode: "M08", day: 1, calendar: "gregory" }, "gregory", "monthCode and non-ISO Gregorian string calendar"],
14 [{ monthCode: "M08", day: 1, calendar: "hebrew" }, "hebrew", "monthCode and non-ISO non-Gregorian string calendar"],
15 ];
16
17 for (const [argument, expectedCalendar, description] of okTests) {
18 const plainMonthDay = Temporal.PlainMonthDay.from(argument);
19 TemporalHelpers.assertPlainMonthDay(plainMonthDay, "M08", 1, description);
20 assert.sameValue(plainMonthDay.calendarId, expectedCalendar, `resulting calendar is ${expectedCalendar}`);
21 }
22
23 const notOkTests = [
24 [{ month: 8, day: 1, calendar: "gregory" }, "month and non-ISO string calendar"],
25 [{ month: 8, day: 1, calendar: "hebrew" }, "month and non-ISO non-Gregorian string calendar"],
26 ];
27
28 for (const [argument, description] of notOkTests) {
29 assert.throws(TypeError, () => Temporal.PlainMonthDay.from(argument), description);
30 }
31
32 reportCompare(0, 0);