mirror of
https://github.com/tc39/test262.git
synced 2025-11-13 18:29:44 +01:00
Add test to verify era aliases for non-gregorian calendars (#4631)
This commit is contained in:
parent
9adf3c0c2f
commit
99aa2c22ec
@ -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)
|
||||||
|
}
|
||||||
@ -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)
|
||||||
|
}
|
||||||
@ -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)
|
||||||
|
}
|
||||||
@ -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)
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user