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

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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

mercurial