summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Collator/prototype/compare/bound-to-collator-instance.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/intl402/Collator/prototype/compare/bound-to-collator-instance.js')
-rw-r--r--js/src/tests/test262/intl402/Collator/prototype/compare/bound-to-collator-instance.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Collator/prototype/compare/bound-to-collator-instance.js b/js/src/tests/test262/intl402/Collator/prototype/compare/bound-to-collator-instance.js
new file mode 100644
index 0000000000..a5d3716700
--- /dev/null
+++ b/js/src/tests/test262/intl402/Collator/prototype/compare/bound-to-collator-instance.js
@@ -0,0 +1,33 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 10.3.2_1_c
+description: Tests that compare function is bound to its Intl.Collator.
+author: Norbert Lindenberg
+includes: [compareArray.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);
+ assert.compareArray(sorted, referenceSorted,
+ "(Testing with locales " + locales + "; options " +
+ (options ? JSON.stringify(options) : options) + ".)");
+ });
+});
+
+reportCompare(0, 0);