Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/overflow-default-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) 2022 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.plaindatetime.from
7 description: By default, overflow = constrain
8 features: [Temporal]
9 includes: [temporalHelpers.js]
10 ---*/
11
12 const date = {year: 2019, month: 1, day: 32};
13 const data = [2019, 1, "M01", 31, 0, 0, 0, 0, 0, 0];
14
15 TemporalHelpers.assertPlainDateTime(
16 Temporal.PlainDateTime.from(date),
17 ...data,
18 "by default, overflow is constrain (overflow options argument absent)"
19 );
20
21 TemporalHelpers.assertPlainDateTime(
22 Temporal.PlainDateTime.from(date, {}),
23 ...data,
24 "by default, overflow is constrain (options argument is empty plain object)"
25 );
26
27 TemporalHelpers.assertPlainDateTime(
28 Temporal.PlainDateTime.from(date, () => {}),
29 ...data,
30 "by default, overflow is constrain (options argument is empty function)"
31 );
32
33
34 TemporalHelpers.assertPlainDateTime(
35 Temporal.PlainDateTime.from(date, {overflow: "constrain"}),
36 ...data,
37 "by default, overflow is constrain (overflow options argument present)"
38 );
39
40 reportCompare(0, 0);