aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/intl402/ch10/10.3/10.3.2_1_c.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/suite/intl402/ch10/10.3/10.3.2_1_c.js')
-rw-r--r--test/suite/intl402/ch10/10.3/10.3.2_1_c.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/suite/intl402/ch10/10.3/10.3.2_1_c.js b/test/suite/intl402/ch10/10.3/10.3.2_1_c.js
new file mode 100644
index 000000000..077961266
--- /dev/null
+++ b/test/suite/intl402/ch10/10.3/10.3.2_1_c.js
@@ -0,0 +1,36 @@
+// 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.", "\uD842\uDFB7野家", "吉野家", "!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;
+ }
+ });
+});
+