From 4a34d84b206c2e737ba6bbf8af75aa7b449e0703 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Sat, 17 Jul 2021 01:22:42 -0700 Subject: [PATCH] Add test for Temporal.Calendar.p.date(Add|FromFields) --- .../Calendar/prototype/date-add/simple.js | 107 +++++++++++++++ .../prototype/date-from-fields/simple.js | 50 +++++++ .../date-from-fields/throws-range-error.js | 124 ++++++++++++++++++ .../date-from-fields/throws-type-error.js | 38 ++++++ 4 files changed, 319 insertions(+) create mode 100644 test/built-ins/Temporal/Calendar/prototype/date-add/simple.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/date-from-fields/simple.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/date-from-fields/throws-range-error.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/date-from-fields/throws-type-error.js diff --git a/test/built-ins/Temporal/Calendar/prototype/date-add/simple.js b/test/built-ins/Temporal/Calendar/prototype/date-add/simple.js new file mode 100644 index 0000000000..32b6657968 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/date-add/simple.js @@ -0,0 +1,107 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dateadd +description: Temporal.Calendar.prototype.dateAdd +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. Set date to ? ToTemporalDate(date). + 5. Set duration to ? ToTemporalDuration(duration). + 6. Set options to ? GetOptionsObject(options). + 7. Let overflow be ? ToTemporalOverflow(options). + 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). + 9. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601"); + +let p1y = new Temporal.Duration(1); +let p4y = new Temporal.Duration(4); +let p5m = new Temporal.Duration(0, 5); +let p1y2m = new Temporal.Duration(1,2); +let p1y4d = new Temporal.Duration(1,0,0,4); +let p1y2m4d = new Temporal.Duration(1,2,0,4); +let p10d = new Temporal.Duration(0,0,0,10); +let p1w = new Temporal.Duration(0,0,1); +let p6w = new Temporal.Duration(0,0,6); +let p2w3d = new Temporal.Duration(0,0,2,3); +let p1y2w = new Temporal.Duration(1,0,2); +let p2m3w = new Temporal.Duration(0,2,3); + +assert.sameValue("2021-02-28", cal.dateAdd("2020-02-29", p1y).toJSON()); +assert.sameValue("2024-02-29", cal.dateAdd("2020-02-29", p4y).toJSON()); +assert.sameValue("2022-07-16", cal.dateAdd("2021-07-16", p1y).toJSON()); + +assert.sameValue("2021-12-16", cal.dateAdd("2021-07-16", p5m).toJSON()); +assert.sameValue("2022-01-16", cal.dateAdd("2021-08-16", p5m).toJSON()); +assert.sameValue("2022-03-31", cal.dateAdd("2021-10-31", p5m).toJSON()); +assert.sameValue("2022-02-28", cal.dateAdd("2021-09-30", p5m).toJSON()); +assert.sameValue("2020-02-29", cal.dateAdd("2019-09-30", p5m).toJSON()); +assert.sameValue("2020-03-01", cal.dateAdd("2019-10-01", p5m).toJSON()); + +assert.sameValue("2022-09-16", cal.dateAdd("2021-07-16", p1y2m).toJSON()); +assert.sameValue("2023-01-30", cal.dateAdd("2021-11-30", p1y2m).toJSON()); +assert.sameValue("2023-02-28", cal.dateAdd("2021-12-31", p1y2m).toJSON()); +assert.sameValue("2024-02-29", cal.dateAdd("2022-12-31", p1y2m).toJSON()); + +assert.sameValue("2022-07-20", cal.dateAdd("2021-07-16", p1y4d).toJSON()); +assert.sameValue("2022-03-03", cal.dateAdd("2021-02-27", p1y4d).toJSON()); +assert.sameValue("2024-03-02", cal.dateAdd("2023-02-27", p1y4d).toJSON()); +assert.sameValue("2023-01-03", cal.dateAdd("2021-12-30", p1y4d).toJSON()); +assert.sameValue("2022-08-03", cal.dateAdd("2021-07-30", p1y4d).toJSON()); +assert.sameValue("2022-07-04", cal.dateAdd("2021-06-30", p1y4d).toJSON()); + +assert.sameValue("2022-09-20", cal.dateAdd("2021-07-16", p1y2m4d).toJSON()); +assert.sameValue("2022-05-01", cal.dateAdd("2021-02-27", p1y2m4d).toJSON()); +assert.sameValue("2022-04-30", cal.dateAdd("2021-02-26", p1y2m4d).toJSON()); +assert.sameValue("2024-04-30", cal.dateAdd("2023-02-26", p1y2m4d).toJSON()); +assert.sameValue("2023-03-04", cal.dateAdd("2021-12-30", p1y2m4d).toJSON()); +assert.sameValue("2022-10-04", cal.dateAdd("2021-07-30", p1y2m4d).toJSON()); +assert.sameValue("2022-09-03", cal.dateAdd("2021-06-30", p1y2m4d).toJSON()); + +assert.sameValue("2021-07-26", cal.dateAdd("2021-07-16", p10d).toJSON()); +assert.sameValue("2021-08-05", cal.dateAdd("2021-07-26", p10d).toJSON()); +assert.sameValue("2022-01-05", cal.dateAdd("2021-12-26", p10d).toJSON()); +assert.sameValue("2020-03-07", cal.dateAdd("2020-02-26", p10d).toJSON()); +assert.sameValue("2021-03-08", cal.dateAdd("2021-02-26", p10d).toJSON()); +assert.sameValue("2020-02-29", cal.dateAdd("2020-02-19", p10d).toJSON()); +assert.sameValue("2021-03-01", cal.dateAdd("2021-02-19", p10d).toJSON()); + +assert.sameValue("2021-02-26", cal.dateAdd("2021-02-19", p1w).toJSON()); +assert.sameValue("2021-03-06", cal.dateAdd("2021-02-27", p1w).toJSON()); +assert.sameValue("2020-03-05", cal.dateAdd("2020-02-27", p1w).toJSON()); +assert.sameValue("2021-12-31", cal.dateAdd("2021-12-24", p1w).toJSON()); +assert.sameValue("2022-01-03", cal.dateAdd("2021-12-27", p1w).toJSON()); +assert.sameValue("2021-02-03", cal.dateAdd("2021-01-27", p1w).toJSON()); +assert.sameValue("2021-07-04", cal.dateAdd("2021-06-27", p1w).toJSON()); +assert.sameValue("2021-08-03", cal.dateAdd("2021-07-27", p1w).toJSON()); + +assert.sameValue("2021-04-02", cal.dateAdd("2021-02-19", p6w).toJSON()); +assert.sameValue("2021-04-10", cal.dateAdd("2021-02-27", p6w).toJSON()); +assert.sameValue("2020-04-09", cal.dateAdd("2020-02-27", p6w).toJSON()); +assert.sameValue("2022-02-04", cal.dateAdd("2021-12-24", p6w).toJSON()); +assert.sameValue("2022-02-07", cal.dateAdd("2021-12-27", p6w).toJSON()); +assert.sameValue("2021-03-10", cal.dateAdd("2021-01-27", p6w).toJSON()); +assert.sameValue("2021-08-08", cal.dateAdd("2021-06-27", p6w).toJSON()); +assert.sameValue("2021-09-07", cal.dateAdd("2021-07-27", p6w).toJSON()); + +assert.sameValue("2020-03-17", cal.dateAdd("2020-02-29", p2w3d).toJSON()); +assert.sameValue("2020-03-16", cal.dateAdd("2020-02-28", p2w3d).toJSON()); +assert.sameValue("2021-03-17", cal.dateAdd("2021-02-28", p2w3d).toJSON()); +assert.sameValue("2021-01-14", cal.dateAdd("2020-12-28", p2w3d).toJSON()); + +assert.sameValue("2021-03-14", cal.dateAdd("2020-02-29", p1y2w).toJSON()); +assert.sameValue("2021-03-14", cal.dateAdd("2020-02-28", p1y2w).toJSON()); +assert.sameValue("2022-03-14", cal.dateAdd("2021-02-28", p1y2w).toJSON()); +assert.sameValue("2022-01-11", cal.dateAdd("2020-12-28", p1y2w).toJSON()); + +assert.sameValue("2020-05-20", cal.dateAdd("2020-02-29", p2m3w).toJSON()); +assert.sameValue("2020-05-19", cal.dateAdd("2020-02-28", p2m3w).toJSON()); +assert.sameValue("2021-05-19", cal.dateAdd("2021-02-28", p2m3w).toJSON()); +assert.sameValue("2021-03-21", cal.dateAdd("2020-12-28", p2m3w).toJSON()); +assert.sameValue("2020-03-20", cal.dateAdd("2019-12-28", p2m3w).toJSON()); +assert.sameValue("2020-01-18", cal.dateAdd("2019-10-28", p2m3w).toJSON()); +assert.sameValue("2020-01-21", cal.dateAdd("2019-10-31", p2m3w).toJSON()); diff --git a/test/built-ins/Temporal/Calendar/prototype/date-from-fields/simple.js b/test/built-ins/Temporal/Calendar/prototype/date-from-fields/simple.js new file mode 100644 index 0000000000..cb455630a4 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/date-from-fields/simple.js @@ -0,0 +1,50 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.calendar.prototype.datefromfields +description: Temporal.Calendar.prototype.dateFromFields +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(fields) is not Object, throw a TypeError exception. + 5. Set options to ? GetOptionsObject(options). + 6. Let result be ? ISODateFromFields(fields, options). + 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601") + +assert.sameValue("2021-07-15", cal.dateFromFields({year: 2021, month: 7, day: 15}).toJSON()); +assert.sameValue("2021-07-03", cal.dateFromFields({year: 2021, month: 7, day: 3}).toJSON()); +assert.sameValue("2021-12-31", cal.dateFromFields({year: 2021, month: 12, day: 31}).toJSON()); +assert.sameValue("2021-07-15", cal.dateFromFields({year: 2021, monthCode: "M07", day: 15}).toJSON()); +assert.sameValue("2021-07-03", cal.dateFromFields({year: 2021, monthCode: "M07", day: 3}).toJSON()); +assert.sameValue("2021-12-31", cal.dateFromFields({year: 2021, monthCode: "M12", day: 31}).toJSON()); + +assert.sameValue("2021-01-31", cal.dateFromFields({year: 2021, month: 1, day: 133}).toJSON()); +assert.sameValue("2021-02-28", cal.dateFromFields({year: 2021, month: 2, day: 133}).toJSON()); +assert.sameValue("2021-03-31", cal.dateFromFields({year: 2021, month: 3, day: 9033}).toJSON()); +assert.sameValue("2021-04-30", cal.dateFromFields({year: 2021, month: 4, day: 50}).toJSON()); +assert.sameValue("2021-05-31", cal.dateFromFields({year: 2021, month: 5, day: 77}).toJSON()); +assert.sameValue("2021-06-30", cal.dateFromFields({year: 2021, month: 6, day: 33}).toJSON()); +assert.sameValue("2021-07-31", cal.dateFromFields({year: 2021, month: 7, day: 33}).toJSON()); +assert.sameValue("2021-08-31", cal.dateFromFields({year: 2021, month: 8, day: 300}).toJSON()); +assert.sameValue("2021-09-30", cal.dateFromFields({year: 2021, month: 9, day: 400}).toJSON()); +assert.sameValue("2021-10-31", cal.dateFromFields({year: 2021, month: 10, day: 400}).toJSON()); +assert.sameValue("2021-11-30", cal.dateFromFields({year: 2021, month: 11, day: 400}).toJSON()); +assert.sameValue("2021-12-31", cal.dateFromFields({year: 2021, month: 12, day: 500}).toJSON()); +assert.sameValue("2021-12-31", cal.dateFromFields({year: 2021, month: 13, day: 500}).toJSON()); +assert.sameValue("2021-12-31", cal.dateFromFields({year: 2021, month: 999999, day: 500}).toJSON()); +assert.sameValue("2021-01-31", cal.dateFromFields({year: 2021, monthCode: "M01", day: 133}).toJSON()); +assert.sameValue("2021-02-28", cal.dateFromFields({year: 2021, monthCode: "M02", day: 133}).toJSON()); +assert.sameValue("2021-03-31", cal.dateFromFields({year: 2021, monthCode: "M03", day: 9033}).toJSON()); +assert.sameValue("2021-04-30", cal.dateFromFields({year: 2021, monthCode: "M04", day: 50}).toJSON()); +assert.sameValue("2021-05-31", cal.dateFromFields({year: 2021, monthCode: "M05", day: 77}).toJSON()); +assert.sameValue("2021-06-30", cal.dateFromFields({year: 2021, monthCode: "M06", day: 33}).toJSON()); +assert.sameValue("2021-07-31", cal.dateFromFields({year: 2021, monthCode: "M07", day: 33}).toJSON()); +assert.sameValue("2021-08-31", cal.dateFromFields({year: 2021, monthCode: "M08", day: 300}).toJSON()); +assert.sameValue("2021-09-30", cal.dateFromFields({year: 2021, monthCode: "M09", day: 400}).toJSON()); +assert.sameValue("2021-10-31", cal.dateFromFields({year: 2021, monthCode: "M10", day: 400}).toJSON()); +assert.sameValue("2021-11-30", cal.dateFromFields({year: 2021, monthCode: "M11", day: 400}).toJSON()); +assert.sameValue("2021-12-31", cal.dateFromFields({year: 2021, monthCode: "M12", day: 500}).toJSON()); diff --git a/test/built-ins/Temporal/Calendar/prototype/date-from-fields/throws-range-error.js b/test/built-ins/Temporal/Calendar/prototype/date-from-fields/throws-range-error.js new file mode 100644 index 0000000000..92e04c427e --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/date-from-fields/throws-range-error.js @@ -0,0 +1,124 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.calendar.prototype.datefromfields +description: Temporal.Calendar.prototype.dateFromFields should throw RangeError for + input not in valid range. +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(fields) is not Object, throw a TypeError exception. + 5. Set options to ? GetOptionsObject(options). + 6. Let result be ? ISODateFromFields(fields, options). + 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601") + +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "m1", day: 17}), + "monthCode value is out of range."); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M1", day: 17}), + "monthCode value is out of range."); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "m01", day: 17}), + "monthCode value is out of range."); + +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 12, monthCode: "M11", day: 17}), + "monthCode value is out of range."); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M00", day: 17}), + "monthCode value is out of range."); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M19", day: 17}), + "monthCode value is out of range."); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M99", day: 17}), + "monthCode value is out of range."); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M13", day: 17}), + "monthCode value is out of range."); + +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: -1, day: 17}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: -Infinity, day: 17}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 7, day: -17}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 7, day: -Infinity}), + "Invalid time value"); + +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 12, day: 0}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 12, day: 32}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 1, day: 32}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 2, day: 29}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 6, day: 31}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 9, day: 31}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 0, day: 5}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 13, day: 5}, {overflow: "reject"}), + "Invalid time value"); + +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, monthCode: "M12", day: 0}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, monthCode: "M12", day: 32}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, monthCode: "M01", day: 32}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, monthCode: "M02", day: 29}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, monthCode: "M06", day: 31}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, monthCode: "M09", day: 31}, {overflow: "reject"}), + "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, monthCode: "M00", day: 5}, {overflow: "reject"}), + "monthCode value is out of range."); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, monthCode: "M13", day: 5}, {overflow: "reject"}), + "monthCode value is out of range."); + +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 12, day: 0}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 0, day: 3}), "Invalid time value"); + +// Check throw for the second arg +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 7, day: 13}, {overflow: "invalid"}), + RangeError, + "Value invalid out of range for Temporal.Calendar.prototype.dateFromFields options property overflow"); + +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 1, day: 32}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 2, day: 29}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 3, day: 32}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 4, day: 31}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 5, day: 32}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 6, day: 31}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 7, day: 32}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 8, day: 32}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 9, day: 31}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 10, day: 32}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 11, day: 31}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 12, day: 32}, {overflow: "reject"}), "Invalid time value"); +assert.throws(RangeError, () => cal.dateFromFields( + {year: 2021, month: 13, day: 5}, {overflow: "reject"}), "Invalid time value"); diff --git a/test/built-ins/Temporal/Calendar/prototype/date-from-fields/throws-type-error.js b/test/built-ins/Temporal/Calendar/prototype/date-from-fields/throws-type-error.js new file mode 100644 index 0000000000..6a70acb4ca --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/date-from-fields/throws-type-error.js @@ -0,0 +1,38 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.calendar.prototype.datefromfields +description: Temporal.Calendar.prototype.dateFromFields should throw TypeError with wrong type. +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(fields) is not Object, throw a TypeError exception. + 5. Set options to ? GetOptionsObject(options). + 6. Let result be ? ISODateFromFields(fields, options). + 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601") + +// Check throw for first arg +assert.throws(TypeError, () => cal.dateFromFields(), + "Temporal.Calendar.prototype.dateFromFields called on non-object"); +[undefined, true, false, 123, 456n, Symbol(), "string"].forEach( + function(fields) { + assert.throws(TypeError, () => cal.dateFromFields(fields), + "Temporal.Calendar.prototype.dateFromFields called on non-object"); + assert.throws(TypeError, () => cal.dateFromFields(fields, undefined), + "Temporal.Calendar.prototype.dateFromFields called on non-object"); + assert.throws(TypeError, () => cal.dateFromFields(fields, {overflow: "constrain"}), + "Temporal.Calendar.prototype.dateFromFields called on non-object"); + assert.throws(TypeError, () => cal.dateFromFields(fields, {overflow: "reject"}), + "Temporal.Calendar.prototype.dateFromFields called on non-object"); + }); + +assert.throws(TypeError, () => cal.dateFromFields({month: 1, day: 17}), + "invalid_argument"); +assert.throws(TypeError, () => cal.dateFromFields({year: 2021, day: 17}), + "invalid_argument"); +assert.throws(TypeError, () => cal.dateFromFields({year: 2021, month: 12}), + "invalid_argument");