Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/intl402/NumberFormat/currency-digits.js

raw
1 // Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
2 // Copyright 2012 Mozilla Corporation. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 es5id: 11.1.1_20_c
7 description: >
8 Tests that the number of fractional digits is determined correctly
9 for currencies.
10 author: Norbert Lindenberg
11 ---*/
12
13 // data from https://www.currency-iso.org/dam/downloads/lists/list_one.xml, 2017-09-22
14 var currencyDigits = {
15 AED: 2,
16 AFN: 2,
17 ALL: 2,
18 AMD: 2,
19 ANG: 2,
20 AOA: 2,
21 ARS: 2,
22 AUD: 2,
23 AWG: 2,
24 AZN: 2,
25 BAM: 2,
26 BBD: 2,
27 BDT: 2,
28 BGN: 2,
29 BHD: 3,
30 BIF: 0,
31 BMD: 2,
32 BND: 2,
33 BOB: 2,
34 BOV: 2,
35 BRL: 2,
36 BSD: 2,
37 BTN: 2,
38 BWP: 2,
39 BYN: 2,
40 BZD: 2,
41 CAD: 2,
42 CDF: 2,
43 CHE: 2,
44 CHF: 2,
45 CHW: 2,
46 CLF: 4,
47 CLP: 0,
48 CNY: 2,
49 COP: 2,
50 COU: 2,
51 CRC: 2,
52 CUC: 2,
53 CUP: 2,
54 CVE: 2,
55 CZK: 2,
56 DJF: 0,
57 DKK: 2,
58 DOP: 2,
59 DZD: 2,
60 EGP: 2,
61 ERN: 2,
62 ETB: 2,
63 EUR: 2,
64 FJD: 2,
65 FKP: 2,
66 GBP: 2,
67 GEL: 2,
68 GHS: 2,
69 GIP: 2,
70 GMD: 2,
71 GNF: 0,
72 GTQ: 2,
73 GYD: 2,
74 HKD: 2,
75 HNL: 2,
76 HRK: 2,
77 HTG: 2,
78 HUF: 2,
79 IDR: 2,
80 ILS: 2,
81 INR: 2,
82 IQD: 3,
83 IRR: 2,
84 ISK: 0,
85 JMD: 2,
86 JOD: 3,
87 JPY: 0,
88 KES: 2,
89 KGS: 2,
90 KHR: 2,
91 KMF: 0,
92 KPW: 2,
93 KRW: 0,
94 KWD: 3,
95 KYD: 2,
96 KZT: 2,
97 LAK: 2,
98 LBP: 2,
99 LKR: 2,
100 LRD: 2,
101 LSL: 2,
102 LYD: 3,
103 MAD: 2,
104 MDL: 2,
105 MGA: 2,
106 MKD: 2,
107 MMK: 2,
108 MNT: 2,
109 MOP: 2,
110 MRO: 2,
111 MUR: 2,
112 MVR: 2,
113 MWK: 2,
114 MXN: 2,
115 MXV: 2,
116 MYR: 2,
117 MZN: 2,
118 NAD: 2,
119 NGN: 2,
120 NIO: 2,
121 NOK: 2,
122 NPR: 2,
123 NZD: 2,
124 OMR: 3,
125 PAB: 2,
126 PEN: 2,
127 PGK: 2,
128 PHP: 2,
129 PKR: 2,
130 PLN: 2,
131 PYG: 0,
132 QAR: 2,
133 RON: 2,
134 RSD: 2,
135 RUB: 2,
136 RWF: 0,
137 SAR: 2,
138 SBD: 2,
139 SCR: 2,
140 SDG: 2,
141 SEK: 2,
142 SGD: 2,
143 SHP: 2,
144 SLL: 2,
145 SOS: 2,
146 SRD: 2,
147 SSP: 2,
148 STD: 2,
149 SVC: 2,
150 SYP: 2,
151 SZL: 2,
152 THB: 2,
153 TJS: 2,
154 TMT: 2,
155 TND: 3,
156 TOP: 2,
157 TRY: 2,
158 TTD: 2,
159 TWD: 2,
160 TZS: 2,
161 UAH: 2,
162 UGX: 0,
163 USD: 2,
164 USN: 2,
165 UYI: 0,
166 UYU: 2,
167 UZS: 2,
168 VEF: 2,
169 VND: 0,
170 VUV: 0,
171 WST: 2,
172 XAF: 0,
173 XCD: 2,
174 XOF: 0,
175 XPF: 0,
176 YER: 2,
177 ZAR: 2,
178 ZMW: 2,
179 ZWL: 2,
180 };
181
182 Object.getOwnPropertyNames(currencyDigits).forEach(function (currency) {
183 var digits = currencyDigits[currency];
184 var format = Intl.NumberFormat([], {style: "currency", currency: currency});
185 var min = format.resolvedOptions().minimumFractionDigits;
186 var max = format.resolvedOptions().maximumFractionDigits;
187 assert.sameValue(min, digits, "Didn't get correct minimumFractionDigits for currency " + currency + ".");
188 assert.sameValue(max, digits, "Didn't get correct maximumFractionDigits for currency " + currency + ".");
189 });