Debian Codegraph @

js/src/tests/test262/intl402/DateTimeFormat/constructor-options-order.js

raw
1 // Copyright 2018 Igalia, S.L. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-createdatetimeformat
6 description: Checks the order of getting options for the DateTimeFormat constructor.
7 includes: [compareArray.js]
8 ---*/
9
10 const expected = [
11 // CreateDateTimeFormat step 4.
12 "localeMatcher",
13 // CreateDateTimeFormat step 12.
14 "hour12",
15 // CreateDateTimeFormat step 13.
16 "hourCycle",
17 // CreateDateTimeFormat step 29.
18 "timeZone",
19 // CreateDateTimeFormat step 36.
20 "weekday",
21 "era",
22 "year",
23 "month",
24 "day",
25 "hour",
26 "minute",
27 "second",
28 "timeZoneName",
29 // CreateDateTimeFormat step 37.
30 "formatMatcher",
31 ];
32
33 const actual = [];
34
35 const options = {
36 get day() {
37 actual.push("day");
38 return "numeric";
39 },
40
41 get era() {
42 actual.push("era");
43 return "long";
44 },
45
46 get formatMatcher() {
47 actual.push("formatMatcher");
48 return "best fit";
49 },
50
51 get hour() {
52 actual.push("hour");
53 return "numeric";
54 },
55
56 get hour12() {
57 actual.push("hour12");
58 return true;
59 },
60
61 get hourCycle() {
62 actual.push("hourCycle");
63 return "h24";
64 },
65
66 get localeMatcher() {
67 actual.push("localeMatcher");
68 return "best fit";
69 },
70
71 get minute() {
72 actual.push("minute");
73 return "numeric";
74 },
75
76 get month() {
77 actual.push("month");
78 return "numeric";
79 },
80
81 get second() {
82 actual.push("second");
83 return "numeric";
84 },
85
86 get timeZone() {
87 actual.push("timeZone");
88 return "UTC";
89 },
90
91 get timeZoneName() {
92 actual.push("timeZoneName");
93 return "long";
94 },
95
96 get weekday() {
97 actual.push("weekday");
98 return "long";
99 },
100
101 get year() {
102 actual.push("year");
103 return "numeric";
104 },
105 };
106
107 new Intl.DateTimeFormat("en", options);
108
109 assert.compareArray(actual, expected);
110
111 reportCompare(0, 0);