diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateFromFields/missing-properties.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateFromFields/missing-properties.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateFromFields/missing-properties.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateFromFields/missing-properties.js new file mode 100644 index 0000000000..6a9ffd5dfc --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateFromFields/missing-properties.js @@ -0,0 +1,48 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2022 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: Errors due to missing properties on fields object are thrown in the correct order +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +const missingDay = { + get year() { + TemporalHelpers.assertUnreachable("day should be checked first"); + }, + get month() { + TemporalHelpers.assertUnreachable("day should be checked first"); + }, + get monthCode() { + TemporalHelpers.assertUnreachable("day should be checked first"); + }, +}; +assert.throws(TypeError, () => instance.dateFromFields(missingDay), "day should be checked before year and month"); + +let getMonth = false; +let getMonthCode = false; +const missingYearAndMonth = { + day: 1, + get month() { + getMonth = true; + }, + get monthCode() { + getMonthCode = true; + }, +}; +assert.throws(TypeError, () => instance.dateFromFields(missingYearAndMonth), "year should be checked after fetching but before resolving the month"); +assert(getMonth, "year is fetched after month"); +assert(getMonthCode, "year is fetched after monthCode"); + +const missingMonth = { + day: 1, + year: 2000, +}; +assert.throws(TypeError, () => instance.dateFromFields(missingMonth), "month should be resolved last"); + +reportCompare(0, 0); |