Skip to content

Commit

Permalink
Temporal: Fix test to check for TypeError with only one of era/eraYear
Browse files Browse the repository at this point in the history
These tests were incorrect, in checking for a RangeError when only one of
the era/eraYear fields were given. From CalendarResolveFields:

"The operation throws a *TypeError* exception if the properties of
_fields_ are internally inconsistent within the calendar or insufficient
to identify a unique instance of _type_ in the calendar."
  • Loading branch information
ptomato committed Sep 19, 2023
1 parent 2cf3fce commit 6f472ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

/*---
esid: sec-temporal.calendar.prototype.datefromfields
description: Throw a RangeError if only one of era/eraYear fields is present
description: Throw a TypeError 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, () => {
assert.throws(TypeError, () => {
instance.dateFromFields({ ...base });
});

const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 };
assert.throws(RangeError, () => {
assert.throws(TypeError, () => {
instance.dateFromFields({ ...base2 });
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

/*---
esid: sec-temporal.calendar.prototype.yearmonthfromfields
description: Throw a RangeError if only one of era/eraYear fields is present
description: Throw a TypeError 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, () => {
assert.throws(TypeError, () => {
instance.yearMonthFromFields({ ...base });
});

const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 };
assert.throws(RangeError, () => {
assert.throws(TypeError, () => {
instance.yearMonthFromFields({ ...base2 });
});

0 comments on commit 6f472ff

Please sign in to comment.