test262/test/suite/intl402/ch10/10.3/10.3.2_1_c.js
Norbert Lindenberg ffe73305c6 New and improved tests for ECMAScript Internationalization API.
- Added test for proleptic Gregorian calendar with no year 0.
- Spelled 𠮷野家 correctly with supplementary characters.
- Fixed default value for useGrouping.
2012-10-04 23:19:33 -07:00

37 lines
1.2 KiB
JavaScript

// Copyright 2012 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @description Tests that compare function is bound to its Intl.Collator.
* @author Norbert Lindenberg
*/
$INCLUDE("testIntl.js");
var strings = ["d", "O", "od", "oe", "of", "ö", "o\u0308", "X", "y", "Z", "Z.", "𠮷野家", "吉野家", "!A", "A", "b", "C"];
var locales = [undefined, ["de"], ["de-u-co-phonebk"], ["en"], ["ja"], ["sv"]];
var options = [
undefined,
{usage: "search"},
{sensitivity: "base", ignorePunctuation: true}
];
locales.forEach(function (locales) {
options.forEach(function (options) {
var collatorObj = new Intl.Collator(locales, options);
var compareFunc = collatorObj.compare;
var referenceSorted = strings.slice();
referenceSorted.sort(function (a, b) { return collatorObj.compare(a, b); });
var sorted = strings;
sorted.sort(compareFunc);
try {
testArraysAreSame(referenceSorted, sorted);
} catch (e) {
e.message += " (Testing with locales " + locales + "; options " +
(options ? JSON.stringify(options) : options) + ".)";
throw e;
}
});
});