Add Temporal era/eraYear tests

This commit is contained in:
Aditi 2023-03-07 19:14:25 +05:30 committed by Philip Chimento
parent c4d8f01d3d
commit 53e5ef817e
6 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,16 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.datefromfields
description: Does not throw a RangeError if only one of era/eraYear fields is present
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const base = { year: 2000, month: 5, day: 2, era: 'ce' };
const instance = new Temporal.Calendar('iso8601');
TemporalHelpers.assertPlainDate(instance.dateFromFields({ ...base }), 2000, 5, 'M05', 2);
const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 };
TemporalHelpers.assertPlainDate(instance.dateFromFields({ ...base }), 2000, 5, 'M05', 2);

View File

@ -0,0 +1,16 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.monthDayFromFields
description: Does not throw a RangeError if only one of era/eraYear fields is present
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const base = { year: 2000, month: 5, day: 2, era: 'ce' };
const instance = new Temporal.Calendar('iso8601');
TemporalHelpers.assertPlainMonthDay(instance.monthDayFromFields({ ...base }), 'M05', 2);
const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 };
TemporalHelpers.assertPlainMonthDay(instance.monthDayFromFields({ ...base }), 'M05', 2);

View File

@ -0,0 +1,16 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.yearMonthFromFields
description: Does not throw a RangeError if only one of era/eraYear fields is present
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const base = { year: 2000, month: 5, day: 2, era: 'ce' };
const instance = new Temporal.Calendar('iso8601');
TemporalHelpers.assertPlainYearMonth(instance.yearMonthFromFields({ ...base }), 2000, 5, 'M05');
const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 };
TemporalHelpers.assertPlainYearMonth(instance.yearMonthFromFields({ ...base }), 2000, 5, 'M05');

View File

@ -0,0 +1,19 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.datefromfields
description: Throw a RangeError if only one of era/eraYear fields is present
features: [Temporal]
---*/
const base = { year: 2000, month: 5, day: 2, era: 'ce' };
const instance = new Temporal.Calendar('gregory');
assert.throws(RangeError, () => {
instance.dateFromFields({ ...base });
});
const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 };
assert.throws(RangeError, () => {
instance.dateFromFields({ ...base2 });
});

View File

@ -0,0 +1,19 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.monthdayfromfields
description: Throw a RangeError if only one of era/eraYear fields is present
features: [Temporal]
---*/
const base = { year: 2000, month: 5, day: 2, era: 'ce' };
const instance = new Temporal.Calendar('gregory');
assert.throws(RangeError, () => {
instance.monthDayFromFields({ ...base });
});
const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 };
assert.throws(RangeError, () => {
instance.dateFromFields({ ...base2 });
});

View File

@ -0,0 +1,19 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.yearmonthfromfields
description: Throw a RangeError if only one of era/eraYear fields is present
features: [Temporal]
---*/
const base = { year: 2000, month: 5, day: 2, era: 'ce' };
const instance = new Temporal.Calendar('gregory');
assert.throws(RangeError, () => {
instance.yearMonthFromFields({ ...base });
});
const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 };
assert.throws(RangeError, () => {
instance.yearMonthFromFields({ ...base2 });
});