diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthDayFromFields/missing-properties.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthDayFromFields/missing-properties.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthDayFromFields/missing-properties.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthDayFromFields/missing-properties.js new file mode 100644 index 0000000000..85331cb3d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthDayFromFields/missing-properties.js @@ -0,0 +1,39 @@ +// |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.monthdayfromfields +description: Errors due to missing properties on fields object are thrown in the correct order +includes: [compareArray.js, 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.monthDayFromFields(missingDay), "day should be checked before year and month"); + +let got = []; +const fieldsSpy = TemporalHelpers.propertyBagObserver(got, { day: 1 }); +assert.throws(TypeError, () => instance.monthDayFromFields(fieldsSpy), "incomplete fields should be rejected (but after reading all non-required fields)"); +assert.compareArray(got, [ + "get day", + "get day.valueOf", + "call day.valueOf", + "get month", + "get monthCode", + "get year", +], "fields should be read in alphabetical order"); + +reportCompare(0, 0); |