diff --git a/test/intl402/Temporal/PlainDate/prototype/with/leap-months-chinese.js b/test/intl402/Temporal/PlainDate/prototype/with/leap-months-chinese.js new file mode 100644 index 0000000000..d4e54e3051 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/with/leap-months-chinese.js @@ -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"); diff --git a/test/intl402/Temporal/PlainDate/prototype/with/leap-months-dangi.js b/test/intl402/Temporal/PlainDate/prototype/with/leap-months-dangi.js new file mode 100644 index 0000000000..c9492e5539 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/with/leap-months-dangi.js @@ -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"); diff --git a/test/intl402/Temporal/PlainDate/prototype/with/leap-months-hebrew.js b/test/intl402/Temporal/PlainDate/prototype/with/leap-months-hebrew.js new file mode 100644 index 0000000000..f16e962f25 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/with/leap-months-hebrew.js @@ -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"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/with/leap-months-chinese.js b/test/intl402/Temporal/PlainDateTime/prototype/with/leap-months-chinese.js new file mode 100644 index 0000000000..f31d787cee --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/with/leap-months-chinese.js @@ -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"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/with/leap-months-dangi.js b/test/intl402/Temporal/PlainDateTime/prototype/with/leap-months-dangi.js new file mode 100644 index 0000000000..f922dc60be --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/with/leap-months-dangi.js @@ -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"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/with/leap-months-hebrew.js b/test/intl402/Temporal/PlainDateTime/prototype/with/leap-months-hebrew.js new file mode 100644 index 0000000000..545c85ba09 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/with/leap-months-hebrew.js @@ -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"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-months-chinese.js b/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-months-chinese.js new file mode 100644 index 0000000000..02a2ae2792 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-months-chinese.js @@ -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"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-months-dangi.js b/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-months-dangi.js new file mode 100644 index 0000000000..a7a18ace5f --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-months-dangi.js @@ -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"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-months-hebrew.js b/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-months-hebrew.js new file mode 100644 index 0000000000..19de9d8006 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/with/leap-months-hebrew.js @@ -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");