test262/test/intl402/Temporal/PlainDate/from/calendar-not-supporting-eras.js
Philip Chimento 6f8f6b5261 Temporal: Tests for ignoring era and eraYear in calendars without eras
This tests some of the prose requirements of CalendarResolveFields.

See https://github.com/tc39/proposal-temporal/issues/2870
2024-09-10 09:28:24 -07:00

49 lines
1.3 KiB
JavaScript

// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.from
description: era and eraYear are ignored (for calendars not using eras)
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const result = Temporal.PlainDate.from({
era: "foobar",
eraYear: 1,
year: 1970,
monthCode: "M01",
day: 1,
calendar: "iso8601",
});
TemporalHelpers.assertPlainDate(result, 1970, 1, "M01", 1,
"era and eraYear are ignored for calendar not using eras (iso8601)");
assert.throws(TypeError, () => Temporal.PlainDate.from({
era: "foobar",
eraYear: 1,
monthCode: "M01",
day: 1,
calendar: "iso8601",
}), "era and eraYear cannot replace year for calendar not using eras (iso8601)");
const resultHebrew = Temporal.PlainDate.from({
era: "foobar",
eraYear: 1,
year: 5780,
monthCode: "M01",
day: 1,
calendar: "hebrew",
});
TemporalHelpers.assertPlainDate(resultHebrew, 5780, 1, "M01", 1,
"era and eraYear are ignored for calendar not using eras (Hebrew)");
assert.sameValue(resultHebrew.calendarId, "hebrew");
assert.throws(TypeError, () => Temporal.PlainDate.from({
era: "foobar",
eraYear: 1,
monthCode: "M01",
day: 1,
calendar: "hebrew",
}), "era and eraYear cannot replace year for calendar not using eras (Hebrew)");