Skip to content

Commit

Permalink
Consolidate duplicate tests
Browse files Browse the repository at this point in the history
There were a few tests already in the tree that overlapped ones that I
added in the previous commit. I've consolidated these and taken
information from the deleted ones where applicable, and improved on the
autogenerated assertion messages.
  • Loading branch information
ptomato authored and jugglinmike committed Oct 1, 2021
1 parent 77a34cf commit 56e537b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ info: |
1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*).
sec-temporal.calendar.prototype.dateadd step 7:
7. Let _overflow_ be ? ToTemporalOverflow(_options_).
features: [Temporal]
features: [Temporal, arrow-function]
---*/

const calendar = new Temporal.Calendar("iso8601");
const date = new Temporal.PlainDate(2000, 5, 2, calendar);
const duration = new Temporal.Duration(3, 3, 0, 3);
assert.throws(RangeError, () => calendar.dateAdd(date, duration, { overflow: "other string" }));
assert.throws(RangeError,
() => calendar.dateAdd(date, duration, { overflow: "other string" }),
"Value for overflow not one of the allowed string values");

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
/*---
esid: sec-temporal.calendar.prototype.datefromfields
description: Throw a TypeError if the fields is not an object
features: [Symbol, Temporal]
info: |
4. If Type(_fields_) is not Object, throw a *TypeError* exception.
features: [BigInt, Symbol, Temporal, arrow-function]
---*/

const tests = [undefined, null, false, "string", Symbol("sym"), Math.PI, 42n];
const tests = [undefined, null, true, false, "string", Symbol("sym"), Infinity, NaN, Math.PI, 42n];
const iso = Temporal.Calendar.from("iso8601");
for (const fields of tests) {
assert.throws(TypeError, () => iso.dateFromFields(fields, {}));
assert.throws(
TypeError,
() => iso.dateFromFields(fields, {})
`dateFromFields(${typeof fields}) throws a TypeError exception`
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ info: |
2. Let _overflow_ be ? ToTemporalOverflow(_options_).
sec-temporal.calendar.prototype.datefromfields step 6:
6. Let _result_ be ? ISODateFromFields(_fields_, _options_).
features: [Temporal]
features: [Temporal, arrow-function]
---*/

const calendar = new Temporal.Calendar("iso8601");
assert.throws(RangeError, () => calendar.dateFromFields({ year: 2000, month: 5, day: 2 }, { overflow: "other string" }));
assert.throws(RangeError, () => calendar.dateFromFields({ year: 2000, month: 5, day: 2 },
{ overflow: "other string" }),
"Value for overflow not one of the allowed string values");

This file was deleted.

This file was deleted.

0 comments on commit 56e537b

Please sign in to comment.