mirror of
https://github.com/tc39/test262.git
synced 2025-11-29 18:13:13 +01:00
Intl Era Monthcode: Constrain day to end-of-month, ISO-like calendars
Similar to the previous commit, this adds tests for constraining the day to the end of the month, but using the with() method. For the four ISO8601-like calendars (buddhist, gregory, japanese, roc).
This commit is contained in:
parent
6d104f134e
commit
5daa33c32b
159
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-buddhist.js
vendored
Normal file
159
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-buddhist.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.with
|
||||
description: Check constraining days to the end of a month (buddhist calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "buddhist";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.PlainDate.from({ year: 2562, monthCode: "M01", day: 31, calendar }, options);
|
||||
const leap0131 = Temporal.PlainDate.from({ year: 2559, monthCode: "M01", day: 31, calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M02" }),
|
||||
2562, 2, "M02", 28, "common-year Feb constrains to 28",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M03" }, options),
|
||||
2562, 3, "M03", 31, "common-year Mar does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M04" }),
|
||||
2562, 4, "M04", 30, "common-year Apr constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M05" }, options),
|
||||
2562, 5, "M05", 31, "common-year May does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M06" }),
|
||||
2562, 6, "M06", 30, "common-year Jun constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M07" }, options),
|
||||
2562, 7, "M07", 31, "common-year Jul does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M08" }, options),
|
||||
2562, 8, "M08", 31, "common-year Aug does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M09" }),
|
||||
2562, 9, "M09", 30, "common-year Sep constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M10" }, options),
|
||||
2562, 10, "M10", 31, "common-year Oct does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M11" }),
|
||||
2562, 11, "M11", 30, "common-year Nov constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M12" }, options),
|
||||
2562, 12, "M12", 31, "common-year Dec does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M02" }),
|
||||
2559, 2, "M02", 29, "leap-year Feb constrains to 29",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M03" }, options),
|
||||
2559, 3, "M03", 31, "leap-year Mar does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M04" }),
|
||||
2559, 4, "M04", 30, "leap-year Apr constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M05" }, options),
|
||||
2559, 5, "M05", 31, "leap-year May does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M06" }),
|
||||
2559, 6, "M06", 30, "leap-year Jun constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M07" }, options),
|
||||
2559, 7, "M07", 31, "leap-year Jul does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M08" }, options),
|
||||
2559, 8, "M08", 31, "leap-year Aug does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M09" }),
|
||||
2559, 9, "M09", 30, "leap-year Sep constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M10" }, options),
|
||||
2559, 10, "M10", 31, "leap-year Oct does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M11" }),
|
||||
2559, 11, "M11", 30, "leap-year Nov constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M12" }, options),
|
||||
2559, 12, "M12", 31, "leap-year Dec does not reject 31",
|
||||
"be", 2559);
|
||||
159
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-gregory.js
vendored
Normal file
159
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-gregory.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.with
|
||||
description: Check constraining days to the end of a month (gregory calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "gregory";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.PlainDate.from({ year: 2019, monthCode: "M01", day: 31, calendar }, options);
|
||||
const leap0131 = Temporal.PlainDate.from({ year: 2016, monthCode: "M01", day: 31, calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M02" }),
|
||||
2019, 2, "M02", 28, "common-year Feb constrains to 28",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M03" }, options),
|
||||
2019, 3, "M03", 31, "common-year Mar does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M04" }),
|
||||
2019, 4, "M04", 30, "common-year Apr constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M05" }, options),
|
||||
2019, 5, "M05", 31, "common-year May does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M06" }),
|
||||
2019, 6, "M06", 30, "common-year Jun constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M07" }, options),
|
||||
2019, 7, "M07", 31, "common-year Jul does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M08" }, options),
|
||||
2019, 8, "M08", 31, "common-year Aug does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M09" }),
|
||||
2019, 9, "M09", 30, "common-year Sep constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M10" }, options),
|
||||
2019, 10, "M10", 31, "common-year Oct does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M11" }),
|
||||
2019, 11, "M11", 30, "common-year Nov constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M12" }, options),
|
||||
2019, 12, "M12", 31, "common-year Dec does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M02" }),
|
||||
2016, 2, "M02", 29, "leap-year Feb constrains to 29",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M03" }, options),
|
||||
2016, 3, "M03", 31, "leap-year Mar does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M04" }),
|
||||
2016, 4, "M04", 30, "leap-year Apr constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M05" }, options),
|
||||
2016, 5, "M05", 31, "leap-year May does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M06" }),
|
||||
2016, 6, "M06", 30, "leap-year Jun constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M07" }, options),
|
||||
2016, 7, "M07", 31, "leap-year Jul does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M08" }, options),
|
||||
2016, 8, "M08", 31, "leap-year Aug does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M09" }),
|
||||
2016, 9, "M09", 30, "leap-year Sep constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M10" }, options),
|
||||
2016, 10, "M10", 31, "leap-year Oct does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M11" }),
|
||||
2016, 11, "M11", 30, "leap-year Nov constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M12" }, options),
|
||||
2016, 12, "M12", 31, "leap-year Dec does not reject 31",
|
||||
"ce", 2016);
|
||||
159
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-japanese.js
vendored
Normal file
159
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-japanese.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.with
|
||||
description: Check constraining days to the end of a month (japanese calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "japanese";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.PlainDate.from({ year: 2019, monthCode: "M01", day: 31, calendar }, options);
|
||||
const leap0131 = Temporal.PlainDate.from({ year: 2016, monthCode: "M01", day: 31, calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M02" }),
|
||||
2019, 2, "M02", 28, "common-year Feb constrains to 28",
|
||||
"heisei", 31);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M03" }, options),
|
||||
2019, 3, "M03", 31, "common-year Mar does not reject 31",
|
||||
"heisei", 31);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M04" }),
|
||||
2019, 4, "M04", 30, "common-year Apr constrains to 30",
|
||||
"heisei", 31);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M05" }, options),
|
||||
2019, 5, "M05", 31, "common-year May does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M06" }),
|
||||
2019, 6, "M06", 30, "common-year Jun constrains to 30",
|
||||
"reiwa", 1);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M07" }, options),
|
||||
2019, 7, "M07", 31, "common-year Jul does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M08" }, options),
|
||||
2019, 8, "M08", 31, "common-year Aug does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M09" }),
|
||||
2019, 9, "M09", 30, "common-year Sep constrains to 30",
|
||||
"reiwa", 1);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M10" }, options),
|
||||
2019, 10, "M10", 31, "common-year Oct does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M11" }),
|
||||
2019, 11, "M11", 30, "common-year Nov constrains to 30",
|
||||
"reiwa", 1);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M12" }, options),
|
||||
2019, 12, "M12", 31, "common-year Dec does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M02" }),
|
||||
2016, 2, "M02", 29, "leap-year Feb constrains to 29",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M03" }, options),
|
||||
2016, 3, "M03", 31, "leap-year Mar does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M04" }),
|
||||
2016, 4, "M04", 30, "leap-year Apr constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M05" }, options),
|
||||
2016, 5, "M05", 31, "leap-year May does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M06" }),
|
||||
2016, 6, "M06", 30, "leap-year Jun constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M07" }, options),
|
||||
2016, 7, "M07", 31, "leap-year Jul does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M08" }, options),
|
||||
2016, 8, "M08", 31, "leap-year Aug does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M09" }),
|
||||
2016, 9, "M09", 30, "leap-year Sep constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M10" }, options),
|
||||
2016, 10, "M10", 31, "leap-year Oct does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M11" }),
|
||||
2016, 11, "M11", 30, "leap-year Nov constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M12" }, options),
|
||||
2016, 12, "M12", 31, "leap-year Dec does not reject 31",
|
||||
"heisei", 28);
|
||||
159
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-roc.js
vendored
Normal file
159
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-roc.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.with
|
||||
description: Check constraining days to the end of a month (roc calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "roc";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.PlainDate.from({ year: 108, monthCode: "M01", day: 31, calendar }, options);
|
||||
const leap0131 = Temporal.PlainDate.from({ year: 105, monthCode: "M01", day: 31, calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M02" }),
|
||||
108, 2, "M02", 28, "common-year Feb constrains to 28",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M03" }, options),
|
||||
108, 3, "M03", 31, "common-year Mar does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M04" }),
|
||||
108, 4, "M04", 30, "common-year Apr constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M05" }, options),
|
||||
108, 5, "M05", 31, "common-year May does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M06" }),
|
||||
108, 6, "M06", 30, "common-year Jun constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M07" }, options),
|
||||
108, 7, "M07", 31, "common-year Jul does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M08" }, options),
|
||||
108, 8, "M08", 31, "common-year Aug does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M09" }),
|
||||
108, 9, "M09", 30, "common-year Sep constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M10" }, options),
|
||||
108, 10, "M10", 31, "common-year Oct does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M11" }),
|
||||
108, 11, "M11", 30, "common-year Nov constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
common0131.with({ monthCode: "M12" }, options),
|
||||
108, 12, "M12", 31, "common-year Dec does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M02" }),
|
||||
105, 2, "M02", 29, "leap-year Feb constrains to 29",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M03" }, options),
|
||||
105, 3, "M03", 31, "leap-year Mar does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M04" }),
|
||||
105, 4, "M04", 30, "leap-year Apr constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M05" }, options),
|
||||
105, 5, "M05", 31, "leap-year May does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M06" }),
|
||||
105, 6, "M06", 30, "leap-year Jun constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M07" }, options),
|
||||
105, 7, "M07", 31, "leap-year Jul does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M08" }, options),
|
||||
105, 8, "M08", 31, "leap-year Aug does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M09" }),
|
||||
105, 9, "M09", 30, "leap-year Sep constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M10" }, options),
|
||||
105, 10, "M10", 31, "leap-year Oct does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M11" }),
|
||||
105, 11, "M11", 30, "leap-year Nov constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDate(
|
||||
leap0131.with({ monthCode: "M12" }, options),
|
||||
105, 12, "M12", 31, "leap-year Dec does not reject 31",
|
||||
"roc", 105);
|
||||
159
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-buddhist.js
vendored
Normal file
159
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-buddhist.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.with
|
||||
description: Check constraining days to the end of a month (buddhist calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "buddhist";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.PlainDateTime.from({ year: 2562, monthCode: "M01", day: 31, hour: 12, minute: 34, calendar }, options);
|
||||
const leap0131 = Temporal.PlainDateTime.from({ year: 2559, monthCode: "M01", day: 31, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M02" }),
|
||||
2562, 2, "M02", 28, 12, 34, 0, 0, 0, 0, "common-year Feb constrains to 28",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M03" }, options),
|
||||
2562, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "common-year Mar does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M04" }),
|
||||
2562, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "common-year Apr constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M05" }, options),
|
||||
2562, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "common-year May does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M06" }),
|
||||
2562, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "common-year Jun constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M07" }, options),
|
||||
2562, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "common-year Jul does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M08" }, options),
|
||||
2562, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "common-year Aug does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M09" }),
|
||||
2562, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "common-year Sep constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M10" }, options),
|
||||
2562, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "common-year Oct does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M11" }),
|
||||
2562, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "common-year Nov constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M12" }, options),
|
||||
2562, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "common-year Dec does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M02" }),
|
||||
2559, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "leap-year Feb constrains to 29",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M03" }, options),
|
||||
2559, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "leap-year Mar does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M04" }),
|
||||
2559, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "leap-year Apr constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M05" }, options),
|
||||
2559, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "leap-year May does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M06" }),
|
||||
2559, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "leap-year Jun constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M07" }, options),
|
||||
2559, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "leap-year Jul does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M08" }, options),
|
||||
2559, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "leap-year Aug does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M09" }),
|
||||
2559, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "leap-year Sep constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M10" }, options),
|
||||
2559, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "leap-year Oct does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M11" }),
|
||||
2559, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "leap-year Nov constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M12" }, options),
|
||||
2559, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "leap-year Dec does not reject 31",
|
||||
"be", 2559);
|
||||
159
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-gregory.js
vendored
Normal file
159
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-gregory.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.with
|
||||
description: Check constraining days to the end of a month (gregory calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "gregory";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M01", day: 31, hour: 12, minute: 34, calendar }, options);
|
||||
const leap0131 = Temporal.PlainDateTime.from({ year: 2016, monthCode: "M01", day: 31, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M02" }),
|
||||
2019, 2, "M02", 28, 12, 34, 0, 0, 0, 0, "common-year Feb constrains to 28",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M03" }, options),
|
||||
2019, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "common-year Mar does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M04" }),
|
||||
2019, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "common-year Apr constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M05" }, options),
|
||||
2019, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "common-year May does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M06" }),
|
||||
2019, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "common-year Jun constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M07" }, options),
|
||||
2019, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "common-year Jul does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M08" }, options),
|
||||
2019, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "common-year Aug does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M09" }),
|
||||
2019, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "common-year Sep constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M10" }, options),
|
||||
2019, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "common-year Oct does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M11" }),
|
||||
2019, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "common-year Nov constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M12" }, options),
|
||||
2019, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "common-year Dec does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M02" }),
|
||||
2016, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "leap-year Feb constrains to 29",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M03" }, options),
|
||||
2016, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "leap-year Mar does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M04" }),
|
||||
2016, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "leap-year Apr constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M05" }, options),
|
||||
2016, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "leap-year May does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M06" }),
|
||||
2016, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "leap-year Jun constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M07" }, options),
|
||||
2016, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "leap-year Jul does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M08" }, options),
|
||||
2016, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "leap-year Aug does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M09" }),
|
||||
2016, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "leap-year Sep constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M10" }, options),
|
||||
2016, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "leap-year Oct does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M11" }),
|
||||
2016, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "leap-year Nov constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M12" }, options),
|
||||
2016, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "leap-year Dec does not reject 31",
|
||||
"ce", 2016);
|
||||
159
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-japanese.js
vendored
Normal file
159
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-japanese.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.with
|
||||
description: Check constraining days to the end of a month (japanese calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "japanese";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M01", day: 31, hour: 12, minute: 34, calendar }, options);
|
||||
const leap0131 = Temporal.PlainDateTime.from({ year: 2016, monthCode: "M01", day: 31, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M02" }),
|
||||
2019, 2, "M02", 28, 12, 34, 0, 0, 0, 0, "common-year Feb constrains to 28",
|
||||
"heisei", 31);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M03" }, options),
|
||||
2019, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "common-year Mar does not reject 31",
|
||||
"heisei", 31);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M04" }),
|
||||
2019, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "common-year Apr constrains to 30",
|
||||
"heisei", 31);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M05" }, options),
|
||||
2019, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "common-year May does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M06" }),
|
||||
2019, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "common-year Jun constrains to 30",
|
||||
"reiwa", 1);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M07" }, options),
|
||||
2019, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "common-year Jul does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M08" }, options),
|
||||
2019, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "common-year Aug does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M09" }),
|
||||
2019, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "common-year Sep constrains to 30",
|
||||
"reiwa", 1);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M10" }, options),
|
||||
2019, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "common-year Oct does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M11" }),
|
||||
2019, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "common-year Nov constrains to 30",
|
||||
"reiwa", 1);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M12" }, options),
|
||||
2019, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "common-year Dec does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M02" }),
|
||||
2016, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "leap-year Feb constrains to 29",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M03" }, options),
|
||||
2016, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "leap-year Mar does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M04" }),
|
||||
2016, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "leap-year Apr constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M05" }, options),
|
||||
2016, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "leap-year May does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M06" }),
|
||||
2016, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "leap-year Jun constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M07" }, options),
|
||||
2016, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "leap-year Jul does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M08" }, options),
|
||||
2016, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "leap-year Aug does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M09" }),
|
||||
2016, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "leap-year Sep constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M10" }, options),
|
||||
2016, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "leap-year Oct does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M11" }),
|
||||
2016, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "leap-year Nov constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M12" }, options),
|
||||
2016, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "leap-year Dec does not reject 31",
|
||||
"heisei", 28);
|
||||
159
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-roc.js
vendored
Normal file
159
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-roc.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.with
|
||||
description: Check constraining days to the end of a month (roc calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "roc";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.PlainDateTime.from({ year: 108, monthCode: "M01", day: 31, hour: 12, minute: 34, calendar }, options);
|
||||
const leap0131 = Temporal.PlainDateTime.from({ year: 105, monthCode: "M01", day: 31, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M02" }),
|
||||
108, 2, "M02", 28, 12, 34, 0, 0, 0, 0, "common-year Feb constrains to 28",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M03" }, options),
|
||||
108, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "common-year Mar does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M04" }),
|
||||
108, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "common-year Apr constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M05" }, options),
|
||||
108, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "common-year May does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M06" }),
|
||||
108, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "common-year Jun constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M07" }, options),
|
||||
108, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "common-year Jul does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M08" }, options),
|
||||
108, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "common-year Aug does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M09" }),
|
||||
108, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "common-year Sep constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M10" }, options),
|
||||
108, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "common-year Oct does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M11" }),
|
||||
108, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "common-year Nov constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M12" }, options),
|
||||
108, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "common-year Dec does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M02" }),
|
||||
105, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "leap-year Feb constrains to 29",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M03" }, options),
|
||||
105, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "leap-year Mar does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M04" }),
|
||||
105, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "leap-year Apr constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M05" }, options),
|
||||
105, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "leap-year May does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M06" }),
|
||||
105, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "leap-year Jun constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M07" }, options),
|
||||
105, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "leap-year Jul does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M08" }, options),
|
||||
105, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "leap-year Aug does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M09" }),
|
||||
105, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "leap-year Sep constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M10" }, options),
|
||||
105, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "leap-year Oct does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M11" }),
|
||||
105, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "leap-year Nov constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M12" }, options),
|
||||
105, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "leap-year Dec does not reject 31",
|
||||
"roc", 105);
|
||||
159
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-buddhist.js
vendored
Normal file
159
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-buddhist.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.with
|
||||
description: Check constraining days to the end of a month (buddhist calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "buddhist";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.ZonedDateTime.from({ year: 2562, monthCode: "M01", day: 31, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const leap0131 = Temporal.ZonedDateTime.from({ year: 2559, monthCode: "M01", day: 31, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M02" }).toPlainDateTime(),
|
||||
2562, 2, "M02", 28, 12, 34, 0, 0, 0, 0, "common-year Feb constrains to 28",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M03" }, options).toPlainDateTime(),
|
||||
2562, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "common-year Mar does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M04" }).toPlainDateTime(),
|
||||
2562, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "common-year Apr constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M05" }, options).toPlainDateTime(),
|
||||
2562, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "common-year May does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M06" }).toPlainDateTime(),
|
||||
2562, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "common-year Jun constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M07" }, options).toPlainDateTime(),
|
||||
2562, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "common-year Jul does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M08" }, options).toPlainDateTime(),
|
||||
2562, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "common-year Aug does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M09" }).toPlainDateTime(),
|
||||
2562, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "common-year Sep constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M10" }, options).toPlainDateTime(),
|
||||
2562, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "common-year Oct does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M11" }).toPlainDateTime(),
|
||||
2562, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "common-year Nov constrains to 30",
|
||||
"be", 2562);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M12" }, options).toPlainDateTime(),
|
||||
2562, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "common-year Dec does not reject 31",
|
||||
"be", 2562);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M02" }).toPlainDateTime(),
|
||||
2559, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "leap-year Feb constrains to 29",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M03" }, options).toPlainDateTime(),
|
||||
2559, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "leap-year Mar does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M04" }).toPlainDateTime(),
|
||||
2559, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "leap-year Apr constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M05" }, options).toPlainDateTime(),
|
||||
2559, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "leap-year May does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M06" }).toPlainDateTime(),
|
||||
2559, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "leap-year Jun constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M07" }, options).toPlainDateTime(),
|
||||
2559, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "leap-year Jul does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M08" }, options).toPlainDateTime(),
|
||||
2559, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "leap-year Aug does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M09" }).toPlainDateTime(),
|
||||
2559, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "leap-year Sep constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M10" }, options).toPlainDateTime(),
|
||||
2559, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "leap-year Oct does not reject 31",
|
||||
"be", 2559);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M11" }).toPlainDateTime(),
|
||||
2559, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "leap-year Nov constrains to 30",
|
||||
"be", 2559);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M12" }, options).toPlainDateTime(),
|
||||
2559, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "leap-year Dec does not reject 31",
|
||||
"be", 2559);
|
||||
159
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-gregory.js
vendored
Normal file
159
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-gregory.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.with
|
||||
description: Check constraining days to the end of a month (gregory calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "gregory";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M01", day: 31, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const leap0131 = Temporal.ZonedDateTime.from({ year: 2016, monthCode: "M01", day: 31, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M02" }).toPlainDateTime(),
|
||||
2019, 2, "M02", 28, 12, 34, 0, 0, 0, 0, "common-year Feb constrains to 28",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M03" }, options).toPlainDateTime(),
|
||||
2019, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "common-year Mar does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M04" }).toPlainDateTime(),
|
||||
2019, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "common-year Apr constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M05" }, options).toPlainDateTime(),
|
||||
2019, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "common-year May does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M06" }).toPlainDateTime(),
|
||||
2019, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "common-year Jun constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M07" }, options).toPlainDateTime(),
|
||||
2019, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "common-year Jul does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M08" }, options).toPlainDateTime(),
|
||||
2019, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "common-year Aug does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M09" }).toPlainDateTime(),
|
||||
2019, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "common-year Sep constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M10" }, options).toPlainDateTime(),
|
||||
2019, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "common-year Oct does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M11" }).toPlainDateTime(),
|
||||
2019, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "common-year Nov constrains to 30",
|
||||
"ce", 2019);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M12" }, options).toPlainDateTime(),
|
||||
2019, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "common-year Dec does not reject 31",
|
||||
"ce", 2019);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M02" }).toPlainDateTime(),
|
||||
2016, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "leap-year Feb constrains to 29",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M03" }, options).toPlainDateTime(),
|
||||
2016, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "leap-year Mar does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M04" }).toPlainDateTime(),
|
||||
2016, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "leap-year Apr constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M05" }, options).toPlainDateTime(),
|
||||
2016, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "leap-year May does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M06" }).toPlainDateTime(),
|
||||
2016, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "leap-year Jun constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M07" }, options).toPlainDateTime(),
|
||||
2016, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "leap-year Jul does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M08" }, options).toPlainDateTime(),
|
||||
2016, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "leap-year Aug does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M09" }).toPlainDateTime(),
|
||||
2016, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "leap-year Sep constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M10" }, options).toPlainDateTime(),
|
||||
2016, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "leap-year Oct does not reject 31",
|
||||
"ce", 2016);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M11" }).toPlainDateTime(),
|
||||
2016, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "leap-year Nov constrains to 30",
|
||||
"ce", 2016);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M12" }, options).toPlainDateTime(),
|
||||
2016, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "leap-year Dec does not reject 31",
|
||||
"ce", 2016);
|
||||
159
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-japanese.js
vendored
Normal file
159
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-japanese.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.with
|
||||
description: Check constraining days to the end of a month (japanese calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "japanese";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M01", day: 31, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const leap0131 = Temporal.ZonedDateTime.from({ year: 2016, monthCode: "M01", day: 31, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M02" }).toPlainDateTime(),
|
||||
2019, 2, "M02", 28, 12, 34, 0, 0, 0, 0, "common-year Feb constrains to 28",
|
||||
"heisei", 31);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M03" }, options).toPlainDateTime(),
|
||||
2019, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "common-year Mar does not reject 31",
|
||||
"heisei", 31);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M04" }).toPlainDateTime(),
|
||||
2019, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "common-year Apr constrains to 30",
|
||||
"heisei", 31);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M05" }, options).toPlainDateTime(),
|
||||
2019, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "common-year May does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M06" }).toPlainDateTime(),
|
||||
2019, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "common-year Jun constrains to 30",
|
||||
"reiwa", 1);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M07" }, options).toPlainDateTime(),
|
||||
2019, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "common-year Jul does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M08" }, options).toPlainDateTime(),
|
||||
2019, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "common-year Aug does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M09" }).toPlainDateTime(),
|
||||
2019, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "common-year Sep constrains to 30",
|
||||
"reiwa", 1);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M10" }, options).toPlainDateTime(),
|
||||
2019, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "common-year Oct does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M11" }).toPlainDateTime(),
|
||||
2019, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "common-year Nov constrains to 30",
|
||||
"reiwa", 1);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M12" }, options).toPlainDateTime(),
|
||||
2019, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "common-year Dec does not reject 31",
|
||||
"reiwa", 1);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M02" }).toPlainDateTime(),
|
||||
2016, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "leap-year Feb constrains to 29",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M03" }, options).toPlainDateTime(),
|
||||
2016, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "leap-year Mar does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M04" }).toPlainDateTime(),
|
||||
2016, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "leap-year Apr constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M05" }, options).toPlainDateTime(),
|
||||
2016, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "leap-year May does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M06" }).toPlainDateTime(),
|
||||
2016, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "leap-year Jun constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M07" }, options).toPlainDateTime(),
|
||||
2016, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "leap-year Jul does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M08" }, options).toPlainDateTime(),
|
||||
2016, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "leap-year Aug does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M09" }).toPlainDateTime(),
|
||||
2016, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "leap-year Sep constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M10" }, options).toPlainDateTime(),
|
||||
2016, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "leap-year Oct does not reject 31",
|
||||
"heisei", 28);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M11" }).toPlainDateTime(),
|
||||
2016, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "leap-year Nov constrains to 30",
|
||||
"heisei", 28);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M12" }, options).toPlainDateTime(),
|
||||
2016, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "leap-year Dec does not reject 31",
|
||||
"heisei", 28);
|
||||
159
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-roc.js
vendored
Normal file
159
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-roc.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.with
|
||||
description: Check constraining days to the end of a month (roc calendar)
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
includes: [temporalHelpers.js]
|
||||
---*/
|
||||
|
||||
const calendar = "roc";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const common0131 = Temporal.ZonedDateTime.from({ year: 108, monthCode: "M01", day: 31, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const leap0131 = Temporal.ZonedDateTime.from({ year: 105, monthCode: "M01", day: 31, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
// Common year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M02" }).toPlainDateTime(),
|
||||
108, 2, "M02", 28, 12, 34, 0, 0, 0, 0, "common-year Feb constrains to 28",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M02" }, options);
|
||||
}, "common-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M03" }, options).toPlainDateTime(),
|
||||
108, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "common-year Mar does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M04" }).toPlainDateTime(),
|
||||
108, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "common-year Apr constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M04" }, options);
|
||||
}, "common-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M05" }, options).toPlainDateTime(),
|
||||
108, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "common-year May does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M06" }).toPlainDateTime(),
|
||||
108, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "common-year Jun constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M06" }, options);
|
||||
}, "common-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M07" }, options).toPlainDateTime(),
|
||||
108, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "common-year Jul does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M08" }, options).toPlainDateTime(),
|
||||
108, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "common-year Aug does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M09" }).toPlainDateTime(),
|
||||
108, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "common-year Sep constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M09" }, options);
|
||||
}, "common-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M10" }, options).toPlainDateTime(),
|
||||
108, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "common-year Oct does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M11" }).toPlainDateTime(),
|
||||
108, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "common-year Nov constrains to 30",
|
||||
"roc", 108);
|
||||
assert.throws(RangeError, function () {
|
||||
common0131.with({ monthCode: "M11" }, options);
|
||||
}, "common-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
common0131.with({ monthCode: "M12" }, options).toPlainDateTime(),
|
||||
108, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "common-year Dec does not reject 31",
|
||||
"roc", 108);
|
||||
|
||||
// Leap year
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M02" }).toPlainDateTime(),
|
||||
105, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "leap-year Feb constrains to 29",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M02" }, options);
|
||||
}, "leap-year Feb rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M03" }, options).toPlainDateTime(),
|
||||
105, 3, "M03", 31, 12, 34, 0, 0, 0, 0, "leap-year Mar does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M04" }).toPlainDateTime(),
|
||||
105, 4, "M04", 30, 12, 34, 0, 0, 0, 0, "leap-year Apr constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M04" }, options);
|
||||
}, "leap-year Apr rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M05" }, options).toPlainDateTime(),
|
||||
105, 5, "M05", 31, 12, 34, 0, 0, 0, 0, "leap-year May does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M06" }).toPlainDateTime(),
|
||||
105, 6, "M06", 30, 12, 34, 0, 0, 0, 0, "leap-year Jun constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M06" }, options);
|
||||
}, "leap-year Jun rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M07" }, options).toPlainDateTime(),
|
||||
105, 7, "M07", 31, 12, 34, 0, 0, 0, 0, "leap-year Jul does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M08" }, options).toPlainDateTime(),
|
||||
105, 8, "M08", 31, 12, 34, 0, 0, 0, 0, "leap-year Aug does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M09" }).toPlainDateTime(),
|
||||
105, 9, "M09", 30, 12, 34, 0, 0, 0, 0, "leap-year Sep constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M09" }, options);
|
||||
}, "leap-year Sep rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M10" }, options).toPlainDateTime(),
|
||||
105, 10, "M10", 31, 12, 34, 0, 0, 0, 0, "leap-year Oct does not reject 31",
|
||||
"roc", 105);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M11" }).toPlainDateTime(),
|
||||
105, 11, "M11", 30, 12, 34, 0, 0, 0, 0, "leap-year Nov constrains to 30",
|
||||
"roc", 105);
|
||||
assert.throws(RangeError, function () {
|
||||
leap0131.with({ monthCode: "M11" }, options);
|
||||
}, "leap-year Nov rejects with 31");
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
leap0131.with({ monthCode: "M12" }, options).toPlainDateTime(),
|
||||
105, 12, "M12", 31, 12, 34, 0, 0, 0, 0, "leap-year Dec does not reject 31",
|
||||
"roc", 105);
|
||||
Loading…
x
Reference in New Issue
Block a user