js/src/tests/test262/intl402/ch06/6.3/6.3.1_b.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 invalid currency codes are not accepted.
     6  * @author Norbert Lindenberg
     7  */
     9 var invalidCurrencyCodes = [
    10     "",
    11     "€",
    12     "$",
    13     "SFr.",
    14     "DM",
    15     "KR₩",
    16     "702",
    17     "ßP",
    18     "ınr"
    19 ];
    21 invalidCurrencyCodes.forEach(function (code) {
    22     var error;
    23     try {
    24         // this must throw an exception for an invalid currency code
    25         var format = new Intl.NumberFormat(["de-de"], {style: "currency", currency: code});
    26     } catch (e) {
    27         error = e;
    28     }
    29     if (error === undefined) {
    30         $ERROR("Invalid currency code '" + code + "' was not rejected.");
    31     } else if (error.name !== "RangeError") {
    32         $ERROR("Invalid currency code '" + code + "' was rejected with wrong error " + error.name + ".");
    33     }
    34 });

mercurial