diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-range-error-from-ISODateFromFields.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-range-error-from-ISODateFromFields.js new file mode 100644 index 0000000000..7971ca7642 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-range-error-from-ISODateFromFields.js @@ -0,0 +1,14 @@ +// 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 Error from ISODateFromFields. +info: | + 6. Let result be ? ISODateFromFields(fields, options). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601") + +assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 7, day: 20}, + {overflow: "invalid garbage"}), + "RangeError should be throw from ISODateFromFields"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-fields-is-not-object.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-fields-is-not-object.js new file mode 100644 index 0000000000..1c71d4bef1 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-fields-is-not-object.js @@ -0,0 +1,17 @@ +// 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 while fields is not object. +info: | + 4. If Type(fields) is not Object, throw a TypeError exception. +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601") + +let notObjectList = [ + null, undefined, "string", Symbol('efg'), true, false, Infinity, NaN, 123, 456n]; +notObjectList.forEach(function(fields) { + assert.throws(TypeError, () => cal.dateFromFields(fields), + "fields is not object"); +}) diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-from-GetOptionsObject.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-from-GetOptionsObject.js new file mode 100644 index 0000000000..acb02bce7b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-from-GetOptionsObject.js @@ -0,0 +1,18 @@ +// 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 from GetOptionsObject. +info: | + 4. If Type(fields) is not Object, throw a TypeError exception. +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601") + +let fields = {year: 2021, month: 7, day: 20}; +let notObjectList = [ + null, "string", Symbol('efg'), true, false, Infinity, NaN, 123, 456n]; +notObjectList.forEach(function(options) { + assert.throws(TypeError, () => cal.dateFromFields(fields, options), + "options is not object"); +}) diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-from-RequireInternalSlot.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-from-RequireInternalSlot.js new file mode 100644 index 0000000000..b053fe630e --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-from-RequireInternalSlot.js @@ -0,0 +1,15 @@ +// 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 while calendar has no [[InitializedTemporalCalendar]] +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601") +let badCal = {dateFromFields: cal.dateFromFields}; + +assert.throws(TypeError, () => badCal.dateFromFields({year: 2021, month: 3, day: 17}), + "calendar has no [[InitializedTemporalCalendar]]");