Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/missing-properties.js

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-temporal.plainyearmonth.from
7 description: Errors due to missing properties on fields object are thrown in the correct order
8 features: [Temporal]
9 ---*/
10
11 let getMonth = false;
12 let getMonthCode = false;
13 const missingYearAndMonth = {
14 get month() {
15 getMonth = true;
16 },
17 get monthCode() {
18 getMonthCode = true;
19 },
20 };
21 assert.throws(TypeError, () => Temporal.PlainYearMonth.from(missingYearAndMonth), "year should be checked after fetching but before resolving the month");
22 assert(getMonth, "year is fetched after month");
23 assert(getMonthCode, "year is fetched after monthCode");
24
25 assert.throws(TypeError, () => Temporal.PlainYearMonth.from({ year: 2000 }), "month should be resolved last");
26
27 reportCompare(0, 0);