Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 leap months when year changes in chinese calendar
features: [Temporal]
includes: [temporalHelpers.js]
---*/

const calendar = "chinese";
const options = { overflow: "reject" };
const leapMonth = Temporal.PlainDate.from({ year: 2017, monthCode: "M06L", day: 1, calendar }, options);

TemporalHelpers.assertPlainDate(
leapMonth.with({ year: 2025 }, options),
2025, 7, "M06L", 1, "month not constrained when moving to another leap year with M06L");

TemporalHelpers.assertPlainDate(
leapMonth.with({ year: 2020 }),
2020, 7, "M06", 1, "month constrained when moving to another leap year without M06L");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2020 }, options);
}, "reject when moving to another leap year without M06L");

TemporalHelpers.assertPlainDate(
leapMonth.with({ year: 2024 }),
2024, 6, "M06", 1, "month constrained when moving to a common year");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2024 }, options);
}, "reject when moving to a common year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 leap months when year changes in dangi calendar
features: [Temporal]
includes: [temporalHelpers.js]
---*/

const calendar = "dangi";
const options = { overflow: "reject" };
const leapMonth = Temporal.PlainDate.from({ year: 2017, monthCode: "M05L", day: 1, calendar }, options);

TemporalHelpers.assertPlainDate(
leapMonth.with({ year: 2009 }, options),
2009, 6, "M05L", 1, "month not constrained when moving to another leap year with M05L");

TemporalHelpers.assertPlainDate(
leapMonth.with({ year: 2020 }),
2020, 6, "M05", 1, "month constrained when moving to another leap year without M05L");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2020 }, options);
}, "reject when moving to another leap year without M05L");

TemporalHelpers.assertPlainDate(
leapMonth.with({ year: 2024 }),
2024, 5, "M05", 1, "month constrained when moving to a common year");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2024 }, options);
}, "reject when moving to a common year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 leap months when year changes in hebrew calendar
features: [Temporal]
includes: [temporalHelpers.js]
---*/

const calendar = "hebrew";
const options = { overflow: "reject" };
const leapMonth = Temporal.PlainDate.from({ year: 5784, monthCode: "M05L", day: 1, calendar }, options);

TemporalHelpers.assertPlainDate(
leapMonth.with({ year: 5782 }, options),
5782, 6, "M05L", 1, "month not constrained when moving to another leap year",
"am", 5782);

TemporalHelpers.assertPlainDate(
leapMonth.with({ year: 5783 }),
5783, 6, "M06", 1, "month constrained when moving to a common year",
"am", 5783);

assert.throws(RangeError, function () {
leapMonth.with({ year: 5783 }, options);
}, "reject when moving to a common year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 leap months when year changes in chinese calendar
features: [Temporal]
includes: [temporalHelpers.js]
---*/

const calendar = "chinese";
const options = { overflow: "reject" };
const leapMonth = Temporal.PlainDateTime.from({ year: 2017, monthCode: "M06L", day: 1, hour: 12, minute: 34, calendar }, options);

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2025 }, options),
2025, 7, "M06L", 1, 12, 34, 0, 0, 0, 0, "month not constrained when moving to another leap year with M06L");

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2020 }),
2020, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "month constrained when moving to another leap year without M06L");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2020 }, options);
}, "reject when moving to another leap year without M06L");

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2024 }),
2024, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "month constrained when moving to a common year");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2024 }, options);
}, "reject when moving to a common year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 leap months when year changes in dangi calendar
features: [Temporal]
includes: [temporalHelpers.js]
---*/

const calendar = "dangi";
const options = { overflow: "reject" };
const leapMonth = Temporal.PlainDateTime.from({ year: 2017, monthCode: "M05L", day: 1, hour: 12, minute: 34, calendar }, options);

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2009 }, options),
2009, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "month not constrained when moving to another leap year with M05L");

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2020 }),
2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "month constrained when moving to another leap year without M05L");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2020 }, options);
}, "reject when moving to another leap year without M05L");

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2024 }),
2024, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "month constrained when moving to a common year");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2024 }, options);
}, "reject when moving to a common year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 leap months when year changes in hebrew calendar
features: [Temporal]
includes: [temporalHelpers.js]
---*/

const calendar = "hebrew";
const options = { overflow: "reject" };
const leapMonth = Temporal.PlainDateTime.from({ year: 5784, monthCode: "M05L", day: 1, hour: 12, minute: 34, calendar }, options);

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 5782 }, options),
5782, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "month not constrained when moving to another leap year",
"am", 5782);

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 5783 }),
5783, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "month constrained when moving to a common year",
"am", 5783);

assert.throws(RangeError, function () {
leapMonth.with({ year: 5783 }, options);
}, "reject when moving to a common year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 leap months when year changes in chinese calendar
features: [Temporal]
includes: [temporalHelpers.js]
---*/

const calendar = "chinese";
const options = { overflow: "reject" };
const leapMonth = Temporal.ZonedDateTime.from({ year: 2017, monthCode: "M06L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2025 }, options).toPlainDateTime(),
2025, 7, "M06L", 1, 12, 34, 0, 0, 0, 0, "month not constrained when moving to another leap year with M06L");

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2020 }).toPlainDateTime(),
2020, 7, "M06", 1, 12, 34, 0, 0, 0, 0, "month constrained when moving to another leap year without M06L");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2020 }, options);
}, "reject when moving to another leap year without M06L");

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2024 }).toPlainDateTime(),
2024, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "month constrained when moving to a common year");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2024 }, options);
}, "reject when moving to a common year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 leap months when year changes in dangi calendar
features: [Temporal]
includes: [temporalHelpers.js]
---*/

const calendar = "dangi";
const options = { overflow: "reject" };
const leapMonth = Temporal.ZonedDateTime.from({ year: 2017, monthCode: "M05L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2009 }, options).toPlainDateTime(),
2009, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "month not constrained when moving to another leap year with M05L");

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2020 }).toPlainDateTime(),
2020, 6, "M05", 1, 12, 34, 0, 0, 0, 0, "month constrained when moving to another leap year without M05L");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2020 }, options);
}, "reject when moving to another leap year without M05L");

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 2024 }).toPlainDateTime(),
2024, 5, "M05", 1, 12, 34, 0, 0, 0, 0, "month constrained when moving to a common year");

assert.throws(RangeError, function () {
leapMonth.with({ year: 2024 }, options);
}, "reject when moving to a common year");
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 leap months when year changes in hebrew calendar
features: [Temporal]
includes: [temporalHelpers.js]
---*/

const calendar = "hebrew";
const options = { overflow: "reject" };
const leapMonth = Temporal.ZonedDateTime.from({ year: 5784, monthCode: "M05L", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 5782 }, options).toPlainDateTime(),
5782, 6, "M05L", 1, 12, 34, 0, 0, 0, 0, "month not constrained when moving to another leap year",
"am", 5782);

TemporalHelpers.assertPlainDateTime(
leapMonth.with({ year: 5783 }).toPlainDateTime(),
5783, 6, "M06", 1, 12, 34, 0, 0, 0, 0, "month constrained when moving to a common year",
"am", 5783);

assert.throws(RangeError, function () {
leapMonth.with({ year: 5783 }, options);
}, "reject when moving to a common year");