aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/intl402/ch13/13.1/13.1.1_7.js
diff options
context:
space:
mode:
authorNorbert Lindenberg <ecmascript@lindenbergsoftware.com>2012-08-26 20:50:24 -0700
committerNorbert Lindenberg <ecmascript@lindenbergsoftware.com>2012-08-26 20:50:24 -0700
commitd71ffa59d5fa2df454bf1c1853b0ccfc87fe3bcd (patch)
tree79aed459cf2d8f9d26f8e0ece825d5e20b1d4650 /test/suite/intl402/ch13/13.1/13.1.1_7.js
parent1af24250750e0a4318ec8efb467245fa0e86c215 (diff)
Added new tests for chapters 10 to 13 of the ECMAScript Internationalization API Specification.
Diffstat (limited to 'test/suite/intl402/ch13/13.1/13.1.1_7.js')
-rw-r--r--test/suite/intl402/ch13/13.1/13.1.1_7.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/suite/intl402/ch13/13.1/13.1.1_7.js b/test/suite/intl402/ch13/13.1/13.1.1_7.js
new file mode 100644
index 000000000..417c5d2e2
--- /dev/null
+++ b/test/suite/intl402/ch13/13.1/13.1.1_7.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.
+
+/**
+ * @description Tests that localeCompare produces the same results as 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 referenceCollator = new Intl.Collator(locales, options);
+ var referenceSorted = strings.slice().sort(referenceCollator.compare);
+
+ strings.sort(function (a, b) { return a.localeCompare(b, locales, options); });
+ try {
+ testArraysAreSame(referenceSorted, strings);
+ } catch (e) {
+ e.message += " (Testing with locales " + locales + "; options " + JSON.stringify(options) + ".)";
+ throw e;
+ }
+ });
+});
+