js/src/tests/test262/intl402/ch10/10.2/10.2.3_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 license found in the LICENSE file.
     4 /**
     5  * @description Tests that Intl.Collator does not accept Unicode locale
     6  *     extension keys and values that are not allowed.
     7  * @author Norbert Lindenberg
     8  */
    10 $INCLUDE("testIntl.js");
    12 var testArray = [
    13         "hello", "你好", "こんにちは",
    14         "pêche", "peché", "1", "9", "10",
    15         "ụ\u031B", "u\u031B\u0323", "ư\u0323", "u\u0323\u031B",
    16         "Å", "Å", "A\u030A"
    17 ];
    19 var defaultCollator = new Intl.Collator();
    20 var defaultOptions = defaultCollator.resolvedOptions();
    21 var defaultOptionsJSON = JSON.stringify(defaultOptions);
    22 var defaultLocale = defaultOptions.locale;
    23 var defaultSortedArray = testArray.slice(0).sort(defaultCollator.compare);
    25 var keyValues = {
    26     "co": ["standard", "search", "invalid"],
    27     "ka": ["noignore", "shifted", "invalid"],
    28     "kb": ["true", "false", "invalid"],
    29     "kc": ["true", "false", "invalid"],
    30     "kh": ["true", "false", "invalid"],
    31     "kk": ["true", "false", "invalid"],
    32     "kr": ["latn-hira-hani", "hani-hira-latn", "invalid"],
    33     "ks": ["level1", "level2", "level3", "level4", "identic", "invalid"],
    34     "vt": ["1234-5678-9abc-edf0", "invalid"]
    35 };
    37 Object.getOwnPropertyNames(keyValues).forEach(function (key) {
    38     keyValues[key].forEach(function (value) {
    39         var collator = new Intl.Collator([defaultLocale + "-u-" + key + "-" + value]);
    40         var options = collator.resolvedOptions();
    41         if (options.locale !== defaultLocale) {
    42             $ERROR("Locale " + options.locale + " is affected by key " +
    43                 key + "; value " + value + ".");
    44         }
    45         if (JSON.stringify(options) !== defaultOptionsJSON) {
    46             $ERROR("Resolved options " + JSON.stringify(options) + " are affected by key " +
    47                 key + "; value " + value + ".");
    48         }
    49         testArraysAreSame(defaultSortedArray, testArray.sort(collator.compare));
    50     });
    51 });

mercurial