Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainTime/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.plaintime.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.plaintime.from step 2:
14 2. Let _overflow_ be ? ToTemporalOverflow(_options_).
15 includes: [temporalHelpers.js]
16 features: [Temporal]
17 ---*/
18
19 const validValues = [
20 new Temporal.PlainTime(12),
21 "12:00",
22 ];
23 validValues.forEach((value) => {
24 const explicit = Temporal.PlainTime.from(value, { overflow: undefined });
25 TemporalHelpers.assertPlainTime(explicit, 12, 0, 0, 0, 0, 0, "overflow is ignored");
26 const implicit = Temporal.PlainTime.from(value, {});
27 TemporalHelpers.assertPlainTime(implicit, 12, 0, 0, 0, 0, 0, "overflow is ignored");
28 const lambda = Temporal.PlainTime.from(value, () => {});
29 TemporalHelpers.assertPlainTime(lambda, 12, 0, 0, 0, 0, 0, "overflow is ignored");
30 });
31
32 const propertyBag = { hour: 26 };
33 const explicit = Temporal.PlainTime.from(propertyBag, { overflow: undefined });
34 TemporalHelpers.assertPlainTime(explicit, 23, 0, 0, 0, 0, 0, "default overflow is constrain");
35 const implicit = Temporal.PlainTime.from(propertyBag, {});
36 TemporalHelpers.assertPlainTime(implicit, 23, 0, 0, 0, 0, 0, "default overflow is constrain");
37 const lambda = Temporal.PlainTime.from(propertyBag, () => {});
38 TemporalHelpers.assertPlainTime(lambda, 23, 0, 0, 0, 0, 0, "default overflow is constrain");
39
40 reportCompare(0, 0);