Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-object-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 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.plaindate.from
7 description: Property bag is correctly converted into PlainDate
8 includes: [temporalHelpers.js]
9 features: [Temporal]
10 ---*/
11
12 const badFields = { year: 2019, month: 1, day: 32 };
13 assert.throws(RangeError, () => Temporal.PlainDate.from(badFields, { overflow: "reject" }),
14 "bad fields with reject");
15 TemporalHelpers.assertPlainDate(Temporal.PlainDate.from(badFields),
16 2019, 1, "M01", 31, "bad fields with missing overflow");
17 TemporalHelpers.assertPlainDate(Temporal.PlainDate.from(badFields, { overflow: "constrain" }),
18 2019, 1, "M01", 31, "bad fields with constrain");
19
20 assert.throws(RangeError,
21 () => Temporal.PlainDate.from({ year: 1976, month: 11, monthCode: "M12", day: 18 }),
22 "month and monthCode must agree");
23
24 assert.throws(TypeError,
25 () => Temporal.PlainDate.from({ year: 2019, day: 15 }),
26 "missing month");
27
28 assert.throws(TypeError,
29 () => Temporal.PlainDate.from({}),
30 "no properties");
31
32 assert.throws(TypeError,
33 () => Temporal.PlainDate.from({ month: 12 }),
34 "missing year, day");
35
36 assert.throws(TypeError,
37 () => Temporal.PlainDate.from({ year: 1976, months: 11, day: 18 }),
38 "misspelled month");
39
40 assert.throws(TypeError,
41 () => Temporal.PlainDate.from({ year: undefined, month: 11, day: 18 }),
42 "year undefined");
43
44 reportCompare(0, 0);