Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/monthcode-invalid.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) 2021 the V8 project authors. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-temporal.plainmonthday.from
7 description: Throw RangeError for an out-of-range, conflicting, or ill-formed monthCode
8 features: [Temporal]
9 ---*/
10
11 ["m1", "M1", "m01"].forEach((monthCode) => {
12 assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ monthCode, day: 17 }),
13 `monthCode '${monthCode}' is not well-formed`);
14 });
15
16 assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ year: 2021, month: 12, monthCode: "M11", day: 17 }),
17 "monthCode and month conflict");
18
19 ["M00", "M19", "M99", "M13", "M00L", "M05L", "M13L"].forEach((monthCode) => {
20 assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ monthCode, day: 17 }),
21 `monthCode '${monthCode}' is not valid for ISO 8601 calendar`);
22 });
23
24 assert.throws(
25 RangeError,
26 () => Temporal.PlainMonthDay.from({ day: 1, monthCode: "L99M", year: Symbol() }),
27 "Month code syntax is validated before year type is validated"
28 );
29
30 assert.throws(
31 TypeError,
32 () => Temporal.PlainMonthDay.from({ day: 1, monthCode: "M99L", year: Symbol() }),
33 "Month code suitability is validated after year type is validated"
34 );
35
36 reportCompare(0, 0);