js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_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 2012 Mozilla Corporation. All rights reserved.
     2 // This code is governed by the BSD license found in the LICENSE file.
     4 /**
     5  * @description Tests that format function is bound to its Intl.NumberFormat.
     6  * @author Norbert Lindenberg
     7  */
     9 $INCLUDE("testIntl.js");
    11 var numbers = [0, -0, 1, -1, 5.5, 123, -123, -123.45, 123.44501, 0.001234,
    12     -0.00000000123, 0.00000000000000000000000000000123, 1.2, 0.0000000012344501,
    13     123445.01, 12344501000000000000000000000000000, -12344501000000000000000000000000000,
    14     Infinity, -Infinity, NaN];
    15 var locales = [undefined, ["de"], ["th-u-nu-thai"], ["en"], ["ja-u-nu-jpanfin"], ["ar-u-nu-arab"]];
    16 var options = [
    17     undefined,
    18     {style: "percent"},
    19     {style: "currency", currency: "EUR", currencyDisplay: "symbol"},
    20     {style: "currency", currency: "IQD", currencyDisplay: "symbol"},
    21     {style: "currency", currency: "KMF", currencyDisplay: "symbol"},
    22     {style: "currency", currency: "CLF", currencyDisplay: "symbol"},
    23     {useGrouping: false, minimumIntegerDigits: 3, minimumFractionDigits: 1, maximumFractionDigits: 3}
    24 ];
    26 locales.forEach(function (locales) {
    27     options.forEach(function (options) {
    28         var formatObj = new Intl.NumberFormat(locales, options);
    29         var formatFunc = formatObj.format;
    30         numbers.forEach(function (number) {
    31             var referenceFormatted = formatObj.format(number);
    32             var formatted = formatFunc(number);
    33             if (referenceFormatted !== formatted) {
    34                 $ERROR("format function produces different result than format method for locales " +
    35                     locales + "; options: " + (options ? JSON.stringify(options) : options) +
    36                     " : " + formatted + " vs. " + referenceFormatted + ".");
    37             }
    38         });
    39     });
    40 });

mercurial