js/src/tests/test262/intl402/ch10/10.3/10.3.2_1_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 compare function is bound to its Intl.Collator.
     6  * @author Norbert Lindenberg
     7  */
     9 $INCLUDE("testIntl.js");
    11 var strings = ["d", "O", "od", "oe", "of", "ö", "o\u0308", "X", "y", "Z", "Z.", "𠮷野家", "吉野家", "!A", "A", "b", "C"];
    12 var locales = [undefined, ["de"], ["de-u-co-phonebk"], ["en"], ["ja"], ["sv"]];
    13 var options = [
    14     undefined,
    15     {usage: "search"},
    16     {sensitivity: "base", ignorePunctuation: true}
    17 ];
    19 locales.forEach(function (locales) {
    20     options.forEach(function (options) {
    21         var collatorObj = new Intl.Collator(locales, options);
    22         var compareFunc = collatorObj.compare;
    23         var referenceSorted = strings.slice();
    24         referenceSorted.sort(function (a, b) { return collatorObj.compare(a, b); });
    25         var sorted = strings;
    26         sorted.sort(compareFunc);
    27         try {
    28             testArraysAreSame(referenceSorted, sorted);
    29         } catch (e) {
    30             e.message += " (Testing with locales " + locales + "; options " +
    31                 (options ? JSON.stringify(options) : options) + ".)";
    32             throw e;
    33         }
    34     });
    35 });

mercurial