js/src/tests/test262/intl402/ch11/11.1/11.1.1_20_c.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial