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.

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

mercurial