mirror of
https://github.com/tc39/test262.git
synced 2025-12-02 19:43:04 +01:00
Intl Era Monthcode: Tests for with() around Gregorian-like leap years
Adds tests for with() in the four calendars with Gregorian-like leap years (buddhist, gregory, japanese, roc).
This commit is contained in:
parent
1648f70ba4
commit
caef6b2082
28
test/intl402/Temporal/PlainDate/prototype/with/leap-year-buddhist.js
vendored
Normal file
28
test/intl402/Temporal/PlainDate/prototype/with/leap-year-buddhist.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (buddhist calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "buddhist";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.PlainDate.from({ year: 2559, monthCode: "M02", day: 29, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.with({ year: 2555 }, options),
|
||||||
|
2555, 2, "M02", 29, "day not constrained when moving to another leap year",
|
||||||
|
"be", 2555);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.with({ year: 2561 }),
|
||||||
|
2561, 2, "M02", 28, "day constrained when moving to a common year",
|
||||||
|
"be", 2561);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 2561 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/PlainDate/prototype/with/leap-year-gregory.js
vendored
Normal file
28
test/intl402/Temporal/PlainDate/prototype/with/leap-year-gregory.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (gregory calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "gregory";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.PlainDate.from({ year: 2016, monthCode: "M02", day: 29, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.with({ year: 2012 }, options),
|
||||||
|
2012, 2, "M02", 29, "day not constrained when moving to another leap year",
|
||||||
|
"ce", 2012);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.with({ year: 2018 }),
|
||||||
|
2018, 2, "M02", 28, "day constrained when moving to a common year",
|
||||||
|
"ce", 2018);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 2018 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/PlainDate/prototype/with/leap-year-japanese.js
vendored
Normal file
28
test/intl402/Temporal/PlainDate/prototype/with/leap-year-japanese.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (japanese calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "japanese";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.PlainDate.from({ year: 2016, monthCode: "M02", day: 29, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.with({ year: 2012 }, options),
|
||||||
|
2012, 2, "M02", 29, "day not constrained when moving to another leap year",
|
||||||
|
"heisei", 24);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.with({ year: 2018 }),
|
||||||
|
2018, 2, "M02", 28, "day constrained when moving to a common year",
|
||||||
|
"heisei", 30);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 2018 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/PlainDate/prototype/with/leap-year-roc.js
vendored
Normal file
28
test/intl402/Temporal/PlainDate/prototype/with/leap-year-roc.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (roc calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "roc";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.PlainDate.from({ year: 105, monthCode: "M02", day: 29, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.with({ year: 101 }, options),
|
||||||
|
101, 2, "M02", 29, "day not constrained when moving to another leap year",
|
||||||
|
"roc", 101);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDate(
|
||||||
|
leapDay.with({ year: 107 }),
|
||||||
|
107, 2, "M02", 28, "day constrained when moving to a common year",
|
||||||
|
"roc", 107);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 107 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-buddhist.js
vendored
Normal file
28
test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-buddhist.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (buddhist calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "buddhist";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.PlainDateTime.from({ year: 2559, monthCode: "M02", day: 29, hour: 12, minute: 34, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2555 }, options),
|
||||||
|
2555, 2, "M02", 29, 12, 34, 0, 0, 0, 0,"day not constrained when moving to another leap year",
|
||||||
|
"be", 2555);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2561 }),
|
||||||
|
2561, 2, "M02", 28, 12, 34, 0, 0, 0, 0,"day constrained when moving to a common year",
|
||||||
|
"be", 2561);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 2561 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-gregory.js
vendored
Normal file
28
test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-gregory.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (gregory calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "gregory";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.PlainDateTime.from({ year: 2016, monthCode: "M02", day: 29, hour: 12, minute: 34, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2012 }, options),
|
||||||
|
2012, 2, "M02", 29, 12, 34, 0, 0, 0, 0,"day not constrained when moving to another leap year",
|
||||||
|
"ce", 2012);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2018 }),
|
||||||
|
2018, 2, "M02", 28, 12, 34, 0, 0, 0, 0,"day constrained when moving to a common year",
|
||||||
|
"ce", 2018);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 2018 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-japanese.js
vendored
Normal file
28
test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-japanese.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (japanese calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "japanese";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.PlainDateTime.from({ year: 2016, monthCode: "M02", day: 29, hour: 12, minute: 34, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2012 }, options),
|
||||||
|
2012, 2, "M02", 29, 12, 34, 0, 0, 0, 0,"day not constrained when moving to another leap year",
|
||||||
|
"heisei", 24);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2018 }),
|
||||||
|
2018, 2, "M02", 28, 12, 34, 0, 0, 0, 0,"day constrained when moving to a common year",
|
||||||
|
"heisei", 30);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 2018 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-roc.js
vendored
Normal file
28
test/intl402/Temporal/PlainDateTime/prototype/with/leap-year-roc.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (roc calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "roc";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.PlainDateTime.from({ year: 105, monthCode: "M02", day: 29, hour: 12, minute: 34, calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 101 }, options),
|
||||||
|
101, 2, "M02", 29, 12, 34, 0, 0, 0, 0,"day not constrained when moving to another leap year",
|
||||||
|
"roc", 101);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 107 }),
|
||||||
|
107, 2, "M02", 28, 12, 34, 0, 0, 0, 0,"day constrained when moving to a common year",
|
||||||
|
"roc", 107);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 107 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-buddhist.js
vendored
Normal file
28
test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-buddhist.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (buddhist calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "buddhist";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.ZonedDateTime.from({ year: 2559, monthCode: "M02", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2555 }, options).toPlainDateTime(),
|
||||||
|
2555, 2, "M02", 29, 12, 34, 0, 0, 0, 0,"day not constrained when moving to another leap year",
|
||||||
|
"be", 2555);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2561 }).toPlainDateTime(),
|
||||||
|
2561, 2, "M02", 28, 12, 34, 0, 0, 0, 0,"day constrained when moving to a common year",
|
||||||
|
"be", 2561);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 2561 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-gregory.js
vendored
Normal file
28
test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-gregory.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (gregory calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "gregory";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.ZonedDateTime.from({ year: 2016, monthCode: "M02", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2012 }, options).toPlainDateTime(),
|
||||||
|
2012, 2, "M02", 29, 12, 34, 0, 0, 0, 0,"day not constrained when moving to another leap year",
|
||||||
|
"ce", 2012);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2018 }).toPlainDateTime(),
|
||||||
|
2018, 2, "M02", 28, 12, 34, 0, 0, 0, 0,"day constrained when moving to a common year",
|
||||||
|
"ce", 2018);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 2018 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-japanese.js
vendored
Normal file
28
test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-japanese.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (japanese calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "japanese";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.ZonedDateTime.from({ year: 2016, monthCode: "M02", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2012 }, options).toPlainDateTime(),
|
||||||
|
2012, 2, "M02", 29, 12, 34, 0, 0, 0, 0,"day not constrained when moving to another leap year",
|
||||||
|
"heisei", 24);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 2018 }).toPlainDateTime(),
|
||||||
|
2018, 2, "M02", 28, 12, 34, 0, 0, 0, 0,"day constrained when moving to a common year",
|
||||||
|
"heisei", 30);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 2018 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
28
test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-roc.js
vendored
Normal file
28
test/intl402/Temporal/ZonedDateTime/prototype/with/leap-year-roc.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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 when year changes (roc calendar)
|
||||||
|
features: [Temporal, Intl.Era-monthcode]
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const calendar = "roc";
|
||||||
|
const options = { overflow: "reject" };
|
||||||
|
|
||||||
|
const leapDay = Temporal.ZonedDateTime.from({ year: 105, monthCode: "M02", day: 29, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 101 }, options).toPlainDateTime(),
|
||||||
|
101, 2, "M02", 29, 12, 34, 0, 0, 0, 0,"day not constrained when moving to another leap year",
|
||||||
|
"roc", 101);
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
leapDay.with({ year: 107 }).toPlainDateTime(),
|
||||||
|
107, 2, "M02", 28, 12, 34, 0, 0, 0, 0,"day constrained when moving to a common year",
|
||||||
|
"roc", 107);
|
||||||
|
|
||||||
|
assert.throws(RangeError, function () {
|
||||||
|
leapDay.with({ year: 107 }, options);
|
||||||
|
}, "reject when moving to a common year");
|
||||||
Loading…
x
Reference in New Issue
Block a user