Debian Codegraph @

js/src/tests/non262/Intl/getCalendarInfo.js

raw
1 // |reftest| skip-if(!this.hasOwnProperty("Intl")||!this.hasOwnProperty("addIntlExtras"))
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 // Tests the getCalendarInfo function with a diverse set of arguments.
7
8 function checkCalendarInfo(info, expected)
9 {
10 assertEq(Object.getPrototypeOf(info), Object.prototype);
11
12 assertEq(info.firstDayOfWeek, expected.firstDayOfWeek);
13 assertEq(info.minDays, expected.minDays);
14 assertDeepEq(info.weekend, expected.weekend);
15 assertEq(info.calendar, expected.calendar);
16 assertEq(info.locale, expected.locale);
17 }
18
19 addIntlExtras(Intl);
20
21 let gCI = Intl.getCalendarInfo;
22
23 assertEq(gCI.length, 1);
24
25 checkCalendarInfo(gCI('en-US'), {
26 firstDayOfWeek: 7,
27 minDays: 1,
28 weekend: [6, 7],
29 calendar: "gregory",
30 locale: "en-US"
31 });
32
33 checkCalendarInfo(gCI('en-IL'), {
34 firstDayOfWeek: 7,
35 minDays: 1,
36 weekend: [5, 6],
37 calendar: "gregory",
38 locale: "en-IL"
39 });
40
41
42 checkCalendarInfo(gCI('en-GB'), {
43 firstDayOfWeek: 1,
44 minDays: 4,
45 weekend: [6, 7],
46 calendar: "gregory",
47 locale: "en-GB"
48 });
49
50
51 checkCalendarInfo(gCI('pl'), {
52 firstDayOfWeek: 1,
53 minDays: 4,
54 weekend: [6, 7],
55 calendar: "gregory",
56 locale: "pl"
57 });
58
59 checkCalendarInfo(gCI('ar-IQ'), {
60 firstDayOfWeek: 6,
61 minDays: 1,
62 weekend: [5, 6],
63 calendar: "gregory",
64 locale: "ar-IQ"
65 });
66
67 checkCalendarInfo(gCI('fa-IR'), {
68 firstDayOfWeek: 6,
69 minDays: 1,
70 weekend: [5],
71 calendar: "persian",
72 locale: "fa-IR"
73 });
74
75 if (typeof reportCompare === 'function')
76 reportCompare(0, 0);