| 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.plainyearmonth.from |
| 7 |
description: Returns correctly with valid data |
| 8 |
includes: [temporalHelpers.js] |
| 9 |
features: [Temporal] |
| 10 |
---*/ |
| 11 |
|
| 12 |
let result = Temporal.PlainYearMonth.from({ year: 2021, month: 7 }); |
| 13 |
TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", "year 2021, month 7"); |
| 14 |
result = Temporal.PlainYearMonth.from({ year: 2021, month: 12 }); |
| 15 |
TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "year 2021, month 12"); |
| 16 |
result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M07" }); |
| 17 |
TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", "year 2021, monthCode M07"); |
| 18 |
result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M12" }); |
| 19 |
TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "year 2021, monthCode M12"); |
| 20 |
|
| 21 |
["constrain", "reject"].forEach((overflow) => { |
| 22 |
const opt = { overflow }; |
| 23 |
result = Temporal.PlainYearMonth.from({ year: 2021, month: 7 }, opt); |
| 24 |
TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", `year 2021, month 7, overflow ${overflow}`); |
| 25 |
result = Temporal.PlainYearMonth.from({ year: 2021, month: 12 }, opt); |
| 26 |
TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", `year 2021, month 12, overflow ${overflow}`); |
| 27 |
result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M07" }, opt); |
| 28 |
TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", `year 2021, monthCode M07, overflow ${overflow}`); |
| 29 |
result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M12" }, opt); |
| 30 |
TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", `year 2021, monthCode M12, overflow ${overflow}`); |
| 31 |
}); |
| 32 |
|
| 33 |
reportCompare(0, 0); |