js/src/tests/test262/intl402/ch09/9.2/9.2.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 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 locales that are reported by resolvedOptions
     6  *     are also reported by supportedLocalesOf.
     7  * @author Norbert Lindenberg
     8  */
    10 $INCLUDE("testIntl.js");
    12 testWithIntlConstructors(function (Constructor) {
    13     var info = getLocaleSupportInfo(Constructor);
    14     // this test should work equally for both matching algorithms
    15     ["lookup", "best fit"].forEach(function (matcher) {
    16         var supportedByConstructor = info.supported.concat(info.byFallback);
    17         var supported = Constructor.supportedLocalesOf(supportedByConstructor,
    18             {localeMatcher: matcher});
    19         // we could check the length first, but it's probably more interesting which locales are missing
    20         var i = 0;
    21         var limit = Math.min(supportedByConstructor.length, supported.length);
    22         while (i < limit && supportedByConstructor[i] === supported[i]) {
    23             i++;
    24         }
    25         if (i < supportedByConstructor.length) {
    26             $ERROR("Locale " + supportedByConstructor[i] +
    27                 " is returned by resolvedOptions but not by supportedLocalesOf.");
    28         } else if (i < supported.length) {
    29             $ERROR("Locale " + supported[i] +
    30                 " is returned by supportedLocalesOf but not by resolvedOptions.");
    31         }
    32     });
    34     // this test is only valid for lookup - best fit may find additional locales supported
    35     var unsupportedByConstructor = info.unsupported;
    36     var supported = Constructor.supportedLocalesOf(unsupportedByConstructor,
    37             {localeMatcher: "lookup"});
    38     if (supported.length > 0) {
    39         $ERROR("Locale " + supported[0] +
    40             " is returned by supportedLocalesOf but not by resolvedOptions.");
    41     }
    43     return true;
    44 });

mercurial