js/src/tests/test262/intl402/ch11/11.1/11.1.2.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 Intl.NumberFormat can be subclassed.
     7  * @author Norbert Lindenberg
     8  */
    10 $INCLUDE("testIntl.js");
    12 // get a number format and have it format an array of numbers for comparison with the subclass
    13 var locales = ["tlh", "id", "en"];
    14 var a = [0, 1, -1, -123456.789, -Infinity, NaN];
    15 var referenceNumberFormat = new Intl.NumberFormat(locales);
    16 var referenceFormatted = a.map(referenceNumberFormat.format);
    18 function MyNumberFormat(locales, options) {
    19     Intl.NumberFormat.call(this, locales, options);
    20     // could initialize MyNumberFormat properties
    21 }
    23 MyNumberFormat.prototype = Object.create(Intl.NumberFormat.prototype);
    24 MyNumberFormat.prototype.constructor = MyNumberFormat;
    25 // could add methods to MyNumberFormat.prototype
    27 var format = new MyNumberFormat(locales);
    28 var actual = a.map(format.format);
    29 testArraysAreSame(referenceFormatted, actual);

mercurial