js/src/tests/test262/intl402/ch06/6.2/6.2.2_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 language tags with invalid subtag sequences are not accepted.
     6  * @author Norbert Lindenberg
     7  */
     9 $INCLUDE("testIntl.js");
    11 var invalidLanguageTags = [
    12     "", // empty tag
    13     "i", // singleton alone
    14     "x", // private use without subtag
    15     "u", // extension singleton in first place
    16     "419", // region code in first place
    17     "u-nu-latn-cu-bob", // extension sequence without language
    18     "hans-cmn-cn", // "hans" could theoretically be a 4-letter language code,
    19                    // but those can't be followed by extlang codes.
    20     "cmn-hans-cn-u-u", // duplicate singleton
    21     "cmn-hans-cn-t-u-ca-u", // duplicate singleton
    22     "de-gregory-gregory", // duplicate variant
    23     "*", // language range
    24     "de-*", // language range
    25     "中文", // non-ASCII letters
    26     "en-ß", // non-ASCII letters
    27     "ıd" // non-ASCII letters
    28 ];
    30 testWithIntlConstructors(function (Constructor) {
    31     invalidLanguageTags.forEach(function (tag) {
    32         var error;
    33         try {
    34             // this must throw an exception for an invalid language tag
    35             var obj = new Constructor([tag]);
    36         } catch (e) {
    37             error = e;
    38         }
    39         if (error === undefined) {
    40             $ERROR("Invalid language tag " + tag + " was not rejected.");
    41         } else if (error.name !== "RangeError") {
    42             $ERROR("Invalid language tag " + tag + " was rejected with wrong error " + error.name + ".");
    43         }
    44     });
    45     return true;
    46 });

mercurial