Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/basic.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) 2021 the V8 project authors. 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: Returns correctly with valid data.
8 includes: [temporalHelpers.js]
9 features: [Temporal]
10 ---*/
11
12 const options = [
13 { overflow: "constrain" },
14 { overflow: "reject" },
15 {},
16 undefined,
17 ];
18 options.forEach((opt) => {
19 const optionsDesc = opt && JSON.stringify(opt);
20 let result = Temporal.PlainMonthDay.from({ year: 2021, month: 7, day: 3 }, opt);
21 TemporalHelpers.assertPlainMonthDay(result, "M07", 3, `month 7, day 3, with year, options = ${optionsDesc}`);
22 result = Temporal.PlainMonthDay.from({ year: 2021, month: 12, day: 31 }, opt);
23 TemporalHelpers.assertPlainMonthDay(result, "M12", 31, `month 12, day 31, with year, options = ${optionsDesc}`);
24 result = Temporal.PlainMonthDay.from({ monthCode: "M07", day: 3 }, opt);
25 TemporalHelpers.assertPlainMonthDay(result, "M07", 3, `monthCode M07, day 3, options = ${optionsDesc}`);
26 result = Temporal.PlainMonthDay.from({ monthCode: "M12", day: 31 }, opt);
27 TemporalHelpers.assertPlainMonthDay(result, "M12", 31, `monthCode M12, day 31, options = ${optionsDesc}`);
28 });
29
30 TemporalHelpers.ISOMonths.forEach(({ month, monthCode, daysInMonth }) => {
31 let result = Temporal.PlainMonthDay.from({ month, day: daysInMonth });
32 TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, `month ${month}, day ${daysInMonth}`);
33
34 result = Temporal.PlainMonthDay.from({ monthCode, day: daysInMonth });
35 TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, `monthCode ${monthCode}, day ${daysInMonth}`);
36 });
37
38 reportCompare(0, 0);