js/src/tests/test262/intl402/ch10/10.3/10.3.2_CS_a.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 Norbert Lindenberg. All rights reserved.
     2 // Copyright 2012 Mozilla Corporation. All rights reserved.
     3 // This code is governed by the license found in the LICENSE file.
     5 /**
     6  * @description Tests that the function returned by Intl.Collator.prototype.compare
     7  *     returns 0 when comparing Strings that are considered canonically equivalent
     8  *     by the Unicode standard.
     9  * @author Norbert Lindenberg
    10  */
    12 var collator = new Intl.Collator();
    13 var pairs = [
    14     // example from Unicode 5.0, section 3.7, definition D70
    15     ["o\u0308", "ö"],
    16     // examples from Unicode 5.0, chapter 3.11
    17     ["ä\u0323", "a\u0323\u0308"],
    18     ["a\u0308\u0323", "a\u0323\u0308"],
    19     ["ạ\u0308", "a\u0323\u0308"],
    20     ["ä\u0306", "a\u0308\u0306"],
    21     ["ă\u0308", "a\u0306\u0308"],
    22     // example from Unicode 5.0, chapter 3.12
    23     ["\u1111\u1171\u11B6", "퓛"],
    24     // examples from UTS 10, Unicode Collation Algorithm
    25     ["Å", "Å"],
    26     ["Å", "A\u030A"],
    27     ["x\u031B\u0323", "x\u0323\u031B"],
    28     ["ự", "ụ\u031B"],
    29     ["ự", "u\u031B\u0323"],
    30     ["ự", "ư\u0323"],
    31     ["ự", "u\u0323\u031B"],
    32     // examples from UAX 15, Unicode Normalization Forms
    33     ["Ç", "C\u0327"],
    34     ["q\u0307\u0323", "q\u0323\u0307"],
    35     ["가", "\u1100\u1161"],
    36     ["Å", "A\u030A"],
    37     ["Ω", "Ω"],
    38     ["Å", "A\u030A"],
    39     ["ô", "o\u0302"],
    40     ["ṩ", "s\u0323\u0307"],
    41     ["ḋ\u0323", "d\u0323\u0307"],
    42     ["ḋ\u0323", "ḍ\u0307"],
    43     ["q\u0307\u0323", "q\u0323\u0307"],
    44     // examples involving supplementary characters from UCD NormalizationTest.txt
    45     ["\uD834\uDD5E", "\uD834\uDD57\uD834\uDD65"],
    46     ["\uD87E\uDC2B", "北"]
    48 ];
    49 var i;
    50 for (i = 0; i < pairs.length; i++) {
    51     var pair = pairs[i];
    52     if (collator.compare(pair[0], pair[1]) !== 0) {
    53         $ERROR("Collator.compare considers " + pair[0] + " (" + toU(pair[0]) +
    54             ") ≠ " + pair[1] + " (" + toU(pair[1]) + ").");
    55     }
    56 }
    58 function toU(s) {
    59     var result = "";
    60     var escape = "\\u0000";
    61     var i;
    62     for (i = 0; i < s.length; i++) {
    63         var hex = s.charCodeAt(i).toString(16);
    64         result += escape.substring(0, escape.length - hex.length) + hex;
    65     }
    66     return result;
    67 }

mercurial