Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainDate/from/with-year-month-day-need-constrain.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 esid: sec-temporal.plaindate.from
6 description: Property bag with year/month/day and need constrain
7 info: |
8 1. Let calendar be the this value.
9 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
10 3. Assert: calendar.[[Identifier]] is "iso8601".
11 4. If Type(fields) is not Object, throw a TypeError exception.
12 5. Set options to ? GetOptionsObject(options).
13 6. Let result be ? ISODateFromFields(fields, options).
14 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).
15 features: [Temporal]
16 includes: [temporalHelpers.js]
17 ---*/
18
19 TemporalHelpers.assertPlainDate(
20 Temporal.PlainDate.from({year: 2021, month: 1, day: 133}),
21 2021, 1, "M01", 31,
22 "year/month/day with day need to be constrained in Jan");
23
24 TemporalHelpers.assertPlainDate(
25 Temporal.PlainDate.from({year: 2021, month: 2, day: 133}),
26 2021, 2, "M02", 28,
27 "year/month/day with day need to be constrained in Feb");
28
29 TemporalHelpers.assertPlainDate(
30 Temporal.PlainDate.from({year: 2021, month: 3, day: 133}),
31 2021, 3, "M03", 31,
32 "year/month/day with day need to be constrained in March");
33
34 TemporalHelpers.assertPlainDate(
35 Temporal.PlainDate.from({year: 2021, month: 4, day: 133}),
36 2021, 4, "M04", 30,
37 "year/month/day with day need to be constrained in April");
38
39 TemporalHelpers.assertPlainDate(
40 Temporal.PlainDate.from({year: 2021, month: 5, day: 133}),
41 2021, 5, "M05", 31,
42 "year/month/day with day need to be constrained in May");
43
44 TemporalHelpers.assertPlainDate(
45 Temporal.PlainDate.from({year: 2021, month: 6, day: 133}),
46 2021, 6, "M06", 30,
47 "year/month/day with day need to be constrained in Jun");
48
49 TemporalHelpers.assertPlainDate(
50 Temporal.PlainDate.from({year: 2021, month: 7, day: 133}),
51 2021, 7, "M07", 31,
52 "year/month/day with day need to be constrained in July");
53
54 TemporalHelpers.assertPlainDate(
55 Temporal.PlainDate.from({year: 2021, month: 8, day: 133}),
56 2021, 8, "M08", 31,
57 "year/month/day with day need to be constrained in Aug");
58
59 TemporalHelpers.assertPlainDate(
60 Temporal.PlainDate.from({year: 2021, month: 9, day: 133}),
61 2021, 9, "M09", 30,
62 "year/month/day with day need to be constrained in Sept.");
63
64 TemporalHelpers.assertPlainDate(
65 Temporal.PlainDate.from({year: 2021, month: 10, day: 133}),
66 2021, 10, "M10", 31,
67 "year/month/day with day need to be constrained in Oct.");
68
69 TemporalHelpers.assertPlainDate(
70 Temporal.PlainDate.from({year: 2021, month: 11, day: 133}),
71 2021, 11, "M11", 30,
72 "year/month/day with day need to be constrained in Nov.");
73
74 TemporalHelpers.assertPlainDate(
75 Temporal.PlainDate.from({year: 2021, month: 12, day: 133}),
76 2021, 12, "M12", 31,
77 "year/month/day with day need to be constrained in Dec.");
78
79 TemporalHelpers.assertPlainDate(
80 Temporal.PlainDate.from({year: 2021, month: 13, day: 500}),
81 2021, 12, "M12", 31,
82 "year/month/day with month and day need to be constrained");
83
84 TemporalHelpers.assertPlainDate(
85 Temporal.PlainDate.from({year: 2021, month: 999999, day: 500}),
86 2021, 12, "M12", 31,
87 "year/month/day with month and day need to be constrained");
88
89 reportCompare(0, 0);