Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainDate/from/overflow-undefined.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: Fallback value for overflow option
8 info: |
9 sec-getoption step 3:
10 3. If _value_ is *undefined*, return _fallback_.
11 sec-temporal-totemporaloverflow step 1:
12 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*).
13 sec-temporal-totemporaldate steps 2–3:
14 2. If Type(_item_) is Object, then
15 ...
16 g. Return ? DateFromFields(_calendar_, _fields_, _options_).
17 3. Perform ? ToTemporalOverflow(_options_).
18 sec-temporal.plaindate.from steps 2–3:
19 2. If Type(_item_) is Object and _item_ has an [[InitializedTemporalDate]] internal slot, then
20 a. Perform ? ToTemporalOverflow(_options_).
21 b. Return ...
22 3. Return ? ToTemporalDate(_item_, _options_).
23 includes: [temporalHelpers.js]
24 features: [Temporal]
25 ---*/
26
27 const validValues = [
28 new Temporal.PlainDate(2000, 5, 2),
29 "2000-05-02",
30 ];
31 validValues.forEach((value) => {
32 const explicit = Temporal.PlainDate.from(value, { overflow: undefined });
33 TemporalHelpers.assertPlainDate(explicit, 2000, 5, "M05", 2, "overflow is ignored");
34 const implicit = Temporal.PlainDate.from(value, {});
35 TemporalHelpers.assertPlainDate(implicit, 2000, 5, "M05", 2, "overflow is ignored");
36 const lambda = Temporal.PlainDate.from(value, () => {});
37 TemporalHelpers.assertPlainDate(lambda, 2000, 5, "M05", 2, "overflow is ignored");
38 });
39
40 const propertyBag = { year: 2000, month: 13, day: 34 };
41 const explicit = Temporal.PlainDate.from(propertyBag, { overflow: undefined });
42 TemporalHelpers.assertPlainDate(explicit, 2000, 12, "M12", 31, "default overflow is constrain");
43 const implicit = Temporal.PlainDate.from(propertyBag, {});
44 TemporalHelpers.assertPlainDate(implicit, 2000, 12, "M12", 31, "default overflow is constrain");
45 const lambda = Temporal.PlainDate.from(propertyBag, () => {});
46 TemporalHelpers.assertPlainDate(lambda, 2000, 12, "M12", 31, "default overflow is constrain");
47
48 reportCompare(0, 0);