js/src/tests/test262/intl402/ch06/6.4/6.4_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 time zone names are not accepted.
     6  * @author Norbert Lindenberg
     7  */
     9 var invalidTimeZoneNames = [
    10     "",
    11     "MEZ", // localized abbreviation
    12     "Pacific Time", // localized long form
    13     "cnsha", // BCP 47 time zone code
    14     "invalid", // as the name says
    15     "Europe/İstanbul", // non-ASCII letter
    16     "asıa/baku", // non-ASCII letter
    17     "europe/brußels"  // non-ASCII letter
    18 ];
    20 invalidTimeZoneNames.forEach(function (name) {
    21     var error;
    22     try {
    23         // this must throw an exception for an invalid time zone name
    24         var format = new Intl.DateTimeFormat(["de-de"], {timeZone: name});
    25     } catch (e) {
    26         error = e;
    27     }
    28     if (error === undefined) {
    29         $ERROR("Invalid time zone name " + name + " was not rejected.");
    30     } else if (error.name !== "RangeError") {
    31         $ERROR("Invalid time zone name " + name + " was rejected with wrong error " + error.name + ".");
    32     }
    33 });

mercurial