mirror of
https://github.com/tc39/test262.git
synced 2025-12-02 19:43:04 +01:00
Intl Era Monthcode: Constrain day in with() in Orthodox calendars
This adds tests for constraining the day when changing the month code using the with() method in the three Orthodox calendars (coptic, ethioaa, ethiopic). Adding years is already covered in the leap-year-*.js tests. The only time that the days need to be constrained to the end of the month is in the epagomenal month (M13), since all the other months always have 30 days.
This commit is contained in:
parent
8adac5c382
commit
370e082653
36
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-coptic.js
vendored
Normal file
36
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-coptic.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 various basic calculations involving constraining days to the end of the
|
||||||
|
epagomenal month (coptic calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "coptic";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
// Years - see leap-year-coptic.js
|
||||||
|
// Months
|
||||||
|
|
||||||
|
const common1230 = Temporal.PlainDate.from({ year: 1738, monthCode: "M12", day: 30, calendar }, options);
|
||||||
|
const leap1230 = Temporal.PlainDate.from({ year: 1739, monthCode: "M12", day: 30, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
common1230.with({ monthCode: "M13" }),
|
||||||
|
1738, 13, "M13", 5, "Changing month constrains to day 5 of common-year epagomenal month",
|
||||||
|
"am", 1738);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
common1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to common-year epagomenal month rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leap1230.with({ monthCode: "M13" }),
|
||||||
|
1739, 13, "M13", 6, "Changing month constrains to day 6 of leap-year epagomenal month",
|
||||||
|
"am", 1739);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leap1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to leap-year epagomenal month rejects");
|
||||||
36
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-ethioaa.js
vendored
Normal file
36
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-ethioaa.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 various basic calculations involving constraining days to the end of the
|
||||||
|
epagomenal month (ethioaa calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "ethioaa";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
// Years - see leap-year-ethioaa.js
|
||||||
|
// Months
|
||||||
|
|
||||||
|
const common1230 = Temporal.PlainDate.from({ year: 7514, monthCode: "M12", day: 30, calendar }, options);
|
||||||
|
const leap1230 = Temporal.PlainDate.from({ year: 7515, monthCode: "M12", day: 30, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
common1230.with({ monthCode: "M13" }),
|
||||||
|
7514, 13, "M13", 5, "Changing month constrains to day 5 of common-year epagomenal month",
|
||||||
|
"aa", 7514);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
common1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to common-year epagomenal month rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leap1230.with({ monthCode: "M13" }),
|
||||||
|
7515, 13, "M13", 6, "Changing month constrains to day 6 of leap-year epagomenal month",
|
||||||
|
"aa", 7515);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leap1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to leap-year epagomenal month rejects");
|
||||||
36
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-ethiopic.js
vendored
Normal file
36
test/intl402/Temporal/PlainDate/prototype/with/constrain-day-ethiopic.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 various basic calculations involving constraining days to the end of the
|
||||||
|
epagomenal month (ethiopic calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "ethiopic";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
// Years - see leap-year-ethiopic.js
|
||||||
|
// Months
|
||||||
|
|
||||||
|
const common1230 = Temporal.PlainDate.from({ year: 2014, monthCode: "M12", day: 30, calendar }, options);
|
||||||
|
const leap1230 = Temporal.PlainDate.from({ year: 2015, monthCode: "M12", day: 30, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
common1230.with({ monthCode: "M13" }),
|
||||||
|
2014, 13, "M13", 5, "Changing month constrains to day 5 of common-year epagomenal month",
|
||||||
|
"am", 2014);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
common1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to common-year epagomenal month rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leap1230.with({ monthCode: "M13" }),
|
||||||
|
2015, 13, "M13", 6, "Changing month constrains to day 6 of leap-year epagomenal month",
|
||||||
|
"am", 2015);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leap1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to leap-year epagomenal month rejects");
|
||||||
36
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-coptic.js
vendored
Normal file
36
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-coptic.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 various basic calculations involving constraining days to the end of the
|
||||||
|
epagomenal month (coptic calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "coptic";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
// Years - see leap-year-coptic.js
|
||||||
|
// Months
|
||||||
|
|
||||||
|
const common1230 = Temporal.PlainDateTime.from({ year: 1738, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
|
||||||
|
const leap1230 = Temporal.PlainDateTime.from({ year: 1739, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
common1230.with({ monthCode: "M13" }),
|
||||||
|
1738, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
|
||||||
|
"am", 1738);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
common1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to common-year epagomenal month rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leap1230.with({ monthCode: "M13" }),
|
||||||
|
1739, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
|
||||||
|
"am", 1739);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leap1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to leap-year epagomenal month rejects");
|
||||||
36
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-ethioaa.js
vendored
Normal file
36
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-ethioaa.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 various basic calculations involving constraining days to the end of the
|
||||||
|
epagomenal month (ethioaa calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "ethioaa";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
// Years - see leap-year-ethioaa.js
|
||||||
|
// Months
|
||||||
|
|
||||||
|
const common1230 = Temporal.PlainDateTime.from({ year: 7514, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
|
||||||
|
const leap1230 = Temporal.PlainDateTime.from({ year: 7515, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
common1230.with({ monthCode: "M13" }),
|
||||||
|
7514, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
|
||||||
|
"aa", 7514);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
common1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to common-year epagomenal month rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leap1230.with({ monthCode: "M13" }),
|
||||||
|
7515, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
|
||||||
|
"aa", 7515);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leap1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to leap-year epagomenal month rejects");
|
||||||
36
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-ethiopic.js
vendored
Normal file
36
test/intl402/Temporal/PlainDateTime/prototype/with/constrain-day-ethiopic.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 various basic calculations involving constraining days to the end of the
|
||||||
|
epagomenal month (ethiopic calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "ethiopic";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
// Years - see leap-year-ethiopic.js
|
||||||
|
// Months
|
||||||
|
|
||||||
|
const common1230 = Temporal.PlainDateTime.from({ year: 2014, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
|
||||||
|
const leap1230 = Temporal.PlainDateTime.from({ year: 2015, monthCode: "M12", day: 30, hour: 12, minute: 34, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
common1230.with({ monthCode: "M13" }),
|
||||||
|
2014, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
|
||||||
|
"am", 2014);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
common1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to common-year epagomenal month rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leap1230.with({ monthCode: "M13" }),
|
||||||
|
2015, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
|
||||||
|
"am", 2015);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leap1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to leap-year epagomenal month rejects");
|
||||||
36
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-coptic.js
vendored
Normal file
36
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-coptic.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 various basic calculations involving constraining days to the end of the
|
||||||
|
epagomenal month (coptic calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "coptic";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
// Years - see leap-year-coptic.js
|
||||||
|
// Months
|
||||||
|
|
||||||
|
const common1230 = Temporal.ZonedDateTime.from({ year: 1738, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||||
|
const leap1230 = Temporal.ZonedDateTime.from({ year: 1739, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
common1230.with({ monthCode: "M13" }).toPlainDateTime(),
|
||||||
|
1738, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
|
||||||
|
"am", 1738);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
common1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to common-year epagomenal month rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leap1230.with({ monthCode: "M13" }).toPlainDateTime(),
|
||||||
|
1739, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
|
||||||
|
"am", 1739);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leap1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to leap-year epagomenal month rejects");
|
||||||
36
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-ethioaa.js
vendored
Normal file
36
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-ethioaa.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 various basic calculations involving constraining days to the end of the
|
||||||
|
epagomenal month (ethioaa calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "ethioaa";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
// Years - see leap-year-ethioaa.js
|
||||||
|
// Months
|
||||||
|
|
||||||
|
const common1230 = Temporal.ZonedDateTime.from({ year: 7514, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||||
|
const leap1230 = Temporal.ZonedDateTime.from({ year: 7515, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
common1230.with({ monthCode: "M13" }).toPlainDateTime(),
|
||||||
|
7514, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
|
||||||
|
"aa", 7514);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
common1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to common-year epagomenal month rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leap1230.with({ monthCode: "M13" }).toPlainDateTime(),
|
||||||
|
7515, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
|
||||||
|
"aa", 7515);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leap1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to leap-year epagomenal month rejects");
|
||||||
36
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-ethiopic.js
vendored
Normal file
36
test/intl402/Temporal/ZonedDateTime/prototype/with/constrain-day-ethiopic.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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 various basic calculations involving constraining days to the end of the
|
||||||
|
epagomenal month (ethiopic calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "ethiopic";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
// Years - see leap-year-ethiopic.js
|
||||||
|
// Months
|
||||||
|
|
||||||
|
const common1230 = Temporal.ZonedDateTime.from({ year: 2014, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||||
|
const leap1230 = Temporal.ZonedDateTime.from({ year: 2015, monthCode: "M12", day: 30, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
common1230.with({ monthCode: "M13" }).toPlainDateTime(),
|
||||||
|
2014, 13, "M13", 5, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 5 of common-year epagomenal month",
|
||||||
|
"am", 2014);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
common1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to common-year epagomenal month rejects");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leap1230.with({ monthCode: "M13" }).toPlainDateTime(),
|
||||||
|
2015, 13, "M13", 6, 12, 34, 0, 0, 0, 0, "Changing month constrains to day 6 of leap-year epagomenal month",
|
||||||
|
"am", 2015);
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leap1230.with({ monthCode: "M13" }, options);
|
||||||
|
}, "Changing month to leap-year epagomenal month rejects");
|
||||||
Loading…
x
Reference in New Issue
Block a user