Add test to verify era aliases for non-gregorian calendars (#4631)

This commit is contained in:
Ben Allen 2025-11-03 01:17:23 -08:00 committed by GitHub
parent 9adf3c0c2f
commit 99aa2c22ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,26 @@
// 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-calendarsupportsera
description: Calendar era code is canonicalized (non-Gregorian calendars)
features: [Temporal, Intl.Era-monthcode]
---*/
const calendarEraAliases = [
{ calendar: "japanese", canonicalizedEra: "ce", alias: "ad" },
{ calendar: "japanese", canonicalizedEra: "bce", alias: "bc" }
];
for (const calendarEraAlias of calendarEraAliases) {
const calendar = Temporal.PlainDate.from({
calendar: calendarEraAlias.calendar,
era: calendarEraAlias.alias,
eraYear: 1,
month: 1,
day: 1
});
assert.sameValue(calendar.era, calendarEraAlias.canonicalizedEra, calendar.era + " should canonicalize to " + calendarEraAlias.canonicalizedEra)
}

View File

@ -0,0 +1,26 @@
// 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.from
description: Calendar era code is canonicalized (non-Gregorian calendars)
features: [Temporal, Intl.Era-monthcode]
---*/
const calendarEraAliases = [
{ calendar: "japanese", canonicalizedEra: "ce", alias: "ad" },
{ calendar: "japanese", canonicalizedEra: "bce", alias: "bc" }
];
for (const calendarEraAlias of calendarEraAliases) {
const calendar = Temporal.PlainDateTime.from({
calendar: calendarEraAlias.calendar,
era: calendarEraAlias.alias,
eraYear: 1,
month: 1,
day: 1
});
assert.sameValue(calendar.era, calendarEraAlias.canonicalizedEra, calendar.era + " should canonicalize to " + calendarEraAlias.canonicalizedEra)
}

View File

@ -0,0 +1,26 @@
// 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-plainyearmonth.from
description: Calendar era code is canonicalized (non-Gregorian calendars)
features: [Temporal, Intl.Era-monthcode]
---*/
const calendarEraAliases = [
{ calendar: "japanese", canonicalizedEra: "ce", alias: "ad" },
{ calendar: "japanese", canonicalizedEra: "bce", alias: "bc" }
];
for (const calendarEraAlias of calendarEraAliases) {
const calendar = Temporal.PlainYearMonth.from({
calendar: calendarEraAlias.calendar,
era: calendarEraAlias.alias,
eraYear: 1,
month: 1,
day: 1
});
assert.sameValue(calendar.era, calendarEraAlias.canonicalizedEra, calendar.era + " should canonicalize to " + calendarEraAlias.canonicalizedEra)
}

View File

@ -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.zonedatetime.from
description: Calendar era code is canonicalized (non-Gregorian calendars)
features: [Temporal, Intl.Era-monthcode]
---*/
const calendarEraAliases = [
{ calendar: "japanese", canonicalizedEra: "ce", alias: "ad" },
{ calendar: "japanese", canonicalizedEra: "bce", alias: "bc" }
];
for (const calendarEraAlias of calendarEraAliases) {
const calendar = Temporal.ZonedDateTime.from({
calendar: calendarEraAlias.calendar,
era: calendarEraAlias.alias,
eraYear: 1,
month: 1,
day: 1,
timeZone: "UTC"
});
assert.sameValue(calendar.era, calendarEraAlias.canonicalizedEra, calendar.era + " should canonicalize to " + calendarEraAlias.canonicalizedEra)
}