js/src/tests/test262/intl402/ch10/10.3/10.3.2_1_c.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:2c3fa926694d
1 // Copyright 2012 Mozilla Corporation. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /**
5 * @description Tests that compare function is bound to its Intl.Collator.
6 * @author Norbert Lindenberg
7 */
8
9 $INCLUDE("testIntl.js");
10
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 ];
18
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 });
36

mercurial