aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/intl402/ch10
diff options
context:
space:
mode:
Diffstat (limited to 'test/suite/intl402/ch10')
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.1_1.js43
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.1_10.js18
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.1_11.js12
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.1_13.js14
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.1_19_b.js44
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.1_19_c.js64
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.1_20.js13
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.1_23.js13
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.1_6.js12
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.2_a.js30
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.3.js19
-rw-r--r--test/suite/intl402/ch10/10.2/10.2.1.js22
-rw-r--r--test/suite/intl402/ch10/10.2/10.2.3_b.js47
-rw-r--r--test/suite/intl402/ch10/10.3/10.3.2_1_c.js36
-rw-r--r--test/suite/intl402/ch10/10.3/10.3.2_CS_a.js56
-rw-r--r--test/suite/intl402/ch10/10.3/10.3.2_CS_b_NN.js22
-rw-r--r--test/suite/intl402/ch10/10.3/10.3.2_CS_c_NN.js22
-rw-r--r--test/suite/intl402/ch10/10.3/10.3.2_CS_d_NN.js34
-rw-r--r--test/suite/intl402/ch10/10.3/10.3.3.js48
-rw-r--r--test/suite/intl402/ch10/10.3/10.3_a.js (renamed from test/suite/intl402/ch10/10.3/10.3.js)0
-rw-r--r--test/suite/intl402/ch10/10.3/10.3_b.js33
-rw-r--r--test/suite/intl402/ch10/10.4/10.4_a.js15
22 files changed, 617 insertions, 0 deletions
diff --git a/test/suite/intl402/ch10/10.1/10.1.1_1.js b/test/suite/intl402/ch10/10.1/10.1.1_1.js
new file mode 100644
index 000000000..432e073fc
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.1_1.js
@@ -0,0 +1,43 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that an object can't be re-initialized as a Collator.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testWithIntlConstructors(function (Constructor) {
+ var obj, error;
+
+ // variant 1: use constructor in a "new" expression
+ obj = new Constructor();
+ try {
+ Intl.Collator.call(obj);
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Re-initializing object created with \"new\" as Collator was not rejected.");
+ } else if (error.name !== "TypeError") {
+ $ERROR("Re-initializing object created with \"new\" as Collator was rejected with wrong error " + error.name + ".");
+ }
+
+ // variant 2: use constructor as a function
+ obj = Constructor.call({});
+ error = undefined;
+ try {
+ Intl.Collator.call(obj);
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Re-initializing object created with constructor as function as Collator was not rejected.");
+ } else if (error.name !== "TypeError") {
+ $ERROR("Re-initializing object created with constructor as function as Collator was rejected with wrong error " + error.name + ".");
+ }
+
+ return true;
+});
+
diff --git a/test/suite/intl402/ch10/10.1/10.1.1_10.js b/test/suite/intl402/ch10/10.1/10.1.1_10.js
new file mode 100644
index 000000000..dd4981264
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.1_10.js
@@ -0,0 +1,18 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the behavior of a Record is not affected by adversarial
+ * changes to Object.prototype.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+taintProperties(["localeMatcher", "kn", "kk", "kf"]);
+
+var locale = new Intl.Collator(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale;
+if (!isCanonicalizedStructurallyValidLanguageTag(locale)) {
+ $ERROR("Collator returns invalid locale " + locale + ".");
+}
+
diff --git a/test/suite/intl402/ch10/10.1/10.1.1_11.js b/test/suite/intl402/ch10/10.1/10.1.1_11.js
new file mode 100644
index 000000000..447fd8b28
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.1_11.js
@@ -0,0 +1,12 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the option localeMatcher is processed correctly.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testOption(Intl.Collator, "localeMatcher", "string", ["lookup", "best fit"], "best fit", {noReturn: true});
+
diff --git a/test/suite/intl402/ch10/10.1/10.1.1_13.js b/test/suite/intl402/ch10/10.1/10.1.1_13.js
new file mode 100644
index 000000000..b0f1bbc8e
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.1_13.js
@@ -0,0 +1,14 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the options numeric, normalization, and caseFirst are processed correctly.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testOption(Intl.Collator, "numeric", "boolean", undefined, undefined, {isOptional: true});
+testOption(Intl.Collator, "normalization", "boolean", undefined, undefined, {isOptional: true});
+testOption(Intl.Collator, "caseFirst", "string", ["upper", "lower", "false"], undefined, {isOptional: true});
+
diff --git a/test/suite/intl402/ch10/10.1/10.1.1_19_b.js b/test/suite/intl402/ch10/10.1/10.1.1_19_b.js
new file mode 100644
index 000000000..f1fef2704
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.1_19_b.js
@@ -0,0 +1,44 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests the special handling of the "co" key in Intl.Collator.
+ * @author Norbert Lindenberg
+ */
+
+function checkCollation(extensionCoValue, usageValue, expectedCollations, expectedUsage) {
+ var requestLocale = extensionCoValue !== undefined ? "de-DE-u-co-" + extensionCoValue : "de-DE";
+ var options = usageValue !== undefined ? { usage: usageValue } : undefined;
+ var collator = new Intl.Collator([requestLocale], options);
+
+ var collation = collator.resolvedOptions().collation;
+ if (expectedCollations.indexOf(collation) === -1) {
+ $ERROR((extensionCoValue === undefined ? "Default collation" : "Collation for \"" + extensionCoValue) +
+ "\" should be " + expectedCollations.join(" or ") + ", but is " + collation + ".");
+ }
+
+ var usage = collator.resolvedOptions().usage;
+ if (expectedUsage !== usage) {
+ $ERROR((usageValue === undefined ? "Default usage" : "Usage") +
+ " should be " + expectedUsage + ", but is " + usage + ".");
+ }
+}
+
+checkCollation(undefined, undefined, ["default"], "sort");
+
+checkCollation("phonebk", undefined, ["phonebk", "default"], "sort");
+
+checkCollation("invalid", undefined, ["default"], "sort");
+
+checkCollation("standard", undefined, ["default"], "sort");
+
+checkCollation("standard", "search", ["default"], "search");
+
+checkCollation("standard", "sort", ["default"], "sort");
+
+checkCollation("search", undefined, ["default"], "sort");
+
+checkCollation("search", "search", ["default"], "search");
+
+checkCollation("search", "sort", ["default"], "sort");
+
diff --git a/test/suite/intl402/ch10/10.1/10.1.1_19_c.js b/test/suite/intl402/ch10/10.1/10.1.1_19_c.js
new file mode 100644
index 000000000..577ef5600
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.1_19_c.js
@@ -0,0 +1,64 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the options numeric, normalization, and caseFirst can be
+ * set through either the locale or the options.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var options = [
+ {key: "kn", property: "numeric", type: "boolean", values: [true, false]},
+ {key: "kk", property: "normalization", type: "boolean", values: [true, false]},
+ {key: "kf", property: "caseFirst", type: "string", values: ["upper", "lower", "false"]}
+];
+
+options.forEach(function (option) {
+ var defaultLocale = new Intl.Collator().resolvedOptions().locale;
+ var collator, opt, result;
+
+ // find out which values are supported for a property in the default locale
+ var supportedValues = [];
+ option.values.forEach(function (value) {
+ opt = {};
+ opt[option.property] = value;
+ collator = new Intl.Collator([defaultLocale], opt);
+ result = collator.resolvedOptions()[option.property];
+ if (result !== undefined && supportedValues.indexOf(result) === -1) {
+ supportedValues.push(result);
+ }
+ });
+
+ // verify that the supported values can also be set through the locale
+ supportedValues.forEach(function (value) {
+ collator = new Intl.Collator([defaultLocale + "-u-" + option.key + "-" + value]);
+ result = collator.resolvedOptions()[option.property];
+ if (result !== value) {
+ $ERROR("Property " + option.property + " couldn't be set through locale extension key " +
+ option.key + "; requested value: " + value + "; actual value: " + result + ".");
+ }
+ });
+
+ // verify that the options setting overrides the locale setting
+ supportedValues.forEach(function (value) {
+ var otherValue;
+ option.values.forEach(function (possibleValue) {
+ if (possibleValue !== value) {
+ otherValue = possibleValue;
+ }
+ });
+ if (otherValue !== undefined) {
+ opt = {};
+ opt[option.property] = value;
+ collator = new Intl.Collator([defaultLocale + "-u-" + option.key + "-" + otherValue], opt);
+ result = collator.resolvedOptions()[option.property];
+ if (result !== value) {
+ $ERROR("Options value for property " + option.property + " doesn't override locale extension key " +
+ option.key + "; requested value: " + value + "; actual value: " + result + ".");
+ }
+ }
+ });
+});
+
diff --git a/test/suite/intl402/ch10/10.1/10.1.1_20.js b/test/suite/intl402/ch10/10.1/10.1.1_20.js
new file mode 100644
index 000000000..97d70c0f9
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.1_20.js
@@ -0,0 +1,13 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the option sensitivity is processed correctly.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+// the fallback is variant only for usage === sort, but that happens to be the fallback for usage
+testOption(Intl.Collator, "sensitivity", "string", ["base", "accent", "case", "variant"], "variant");
+
diff --git a/test/suite/intl402/ch10/10.1/10.1.1_23.js b/test/suite/intl402/ch10/10.1/10.1.1_23.js
new file mode 100644
index 000000000..0b5261509
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.1_23.js
@@ -0,0 +1,13 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the option ignorePunctuation is processed correctly.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+// the fallback is variant only for usage === sort, but that happens to be the fallback for usage
+testOption(Intl.Collator, "ignorePunctuation", "boolean", undefined, false);
+
diff --git a/test/suite/intl402/ch10/10.1/10.1.1_6.js b/test/suite/intl402/ch10/10.1/10.1.1_6.js
new file mode 100644
index 000000000..bc13436d7
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.1_6.js
@@ -0,0 +1,12 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the option usage is processed correctly.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testOption(Intl.Collator, "usage", "string", ["sort", "search"], "sort");
+
diff --git a/test/suite/intl402/ch10/10.1/10.1.2_a.js b/test/suite/intl402/ch10/10.1/10.1.2_a.js
new file mode 100644
index 000000000..de69a4809
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.2_a.js
@@ -0,0 +1,30 @@
+// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that Intl.Collator can be subclassed.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+// get a collator and have it sort an array for comparison with the subclass
+var locales = ["tlh", "id", "en"];
+var a = ["A", "C", "E", "B", "D", "F"];
+var referenceCollator = new Intl.Collator(locales);
+var referenceSorted = a.slice().sort(referenceCollator.compare);
+
+function MyCollator(locales, options) {
+ Intl.Collator.call(this, locales, options);
+ // could initialize MyCollator properties
+}
+
+MyCollator.prototype = Object.create(Intl.Collator.prototype);
+MyCollator.prototype.constructor = MyCollator;
+// could add methods to MyCollator.prototype
+
+var collator = new MyCollator(locales);
+a.sort(collator.compare);
+testArraysAreSame(referenceSorted, a);
+
diff --git a/test/suite/intl402/ch10/10.1/10.1.3.js b/test/suite/intl402/ch10/10.1/10.1.3.js
new file mode 100644
index 000000000..7459d98d6
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.3.js
@@ -0,0 +1,19 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that objects constructed by Intl.Collator have the specified internal properties.
+ * @author Norbert Lindenberg
+ */
+
+var obj = new Intl.Collator();
+
+var actualPrototype = Object.getPrototypeOf(obj);
+if (actualPrototype !== Intl.Collator.prototype) {
+ $ERROR("Prototype of object constructed by Intl.Collator isn't Intl.Collator.prototype; got " + actualPrototype);
+}
+
+if (!Object.isExtensible(obj)) {
+ $ERROR("Object constructed by Intl.Collator must be extensible.");
+}
+
diff --git a/test/suite/intl402/ch10/10.2/10.2.1.js b/test/suite/intl402/ch10/10.2/10.2.1.js
new file mode 100644
index 000000000..9eccb073c
--- /dev/null
+++ b/test/suite/intl402/ch10/10.2/10.2.1.js
@@ -0,0 +1,22 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/**
+ * @description Tests that Intl.Collator.prototype has the required attributes.
+ * @author Norbert Lindenberg
+ */
+
+var desc = Object.getOwnPropertyDescriptor(Intl.Collator, "prototype");
+if (desc === undefined) {
+ $ERROR("Intl.Collator.prototype is not defined.");
+}
+if (desc.writable) {
+ $ERROR("Intl.Collator.prototype must not be writable.");
+}
+if (desc.enumerable) {
+ $ERROR("Intl.Collator.prototype must not be enumerable.");
+}
+if (desc.configurable) {
+ $ERROR("Intl.Collator.prototype must not be configurable.");
+}
+
diff --git a/test/suite/intl402/ch10/10.2/10.2.3_b.js b/test/suite/intl402/ch10/10.2/10.2.3_b.js
new file mode 100644
index 000000000..7e727d437
--- /dev/null
+++ b/test/suite/intl402/ch10/10.2/10.2.3_b.js
@@ -0,0 +1,47 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/**
+ * @description Tests that Intl.Collator does not accept Unicode locale
+ * extension keys and values that are not allowed.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var defaultCollator = new Intl.Collator();
+var defaultOptions = defaultCollator.resolvedOptions();
+var defaultOptionsJSON = JSON.stringify(defaultOptions);
+var defaultLocale = defaultOptions.locale;
+var defaultSortedArray = ["hello", "你好", "こんにちは", "pêche", "peché", "9", "10"].sort(defaultCollator.compare);
+
+
+var keyValues = {
+ "co": ["standard", "search", "invalid"],
+ "ka": ["noignore", "shifted", "invalid"],
+ "kb": ["true", "false", "invalid"],
+ "kc": ["true", "false", "invalid"],
+ "kh": ["true", "false", "invalid"],
+ "kr": ["latn-hira-hani", "hani-hira-latn", "invalid"],
+ "ks": ["level1", "level2", "level3", "level4", "identic", "invalid"],
+ "vt": ["1234-5678-9abc-edf0", "invalid"]
+};
+
+var testArray = defaultSortedArray.slice(0);
+
+Object.getOwnPropertyNames(keyValues).forEach(function (key) {
+ keyValues[key].forEach(function (value) {
+ var collator = new Intl.Collator([defaultLocale + "-u-" + key + "-" + value]);
+ var options = collator.resolvedOptions();
+ if (options.locale !== defaultLocale) {
+ $ERROR("Locale " + options.locale + " is affected by key " +
+ key + "; value " + value + ".");
+ }
+ if (JSON.stringify(options) !== defaultOptionsJSON) {
+ $ERROR("Resolved options " + JSON.stringify(options) + " are affected by key " +
+ key + "; value " + value + ".");
+ }
+ testArraysAreSame(defaultSortedArray, testArray.sort(collator.compare));
+ });
+});
+
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;
+ }
+ });
+});
+
diff --git a/test/suite/intl402/ch10/10.3/10.3.2_CS_a.js b/test/suite/intl402/ch10/10.3/10.3.2_CS_a.js
new file mode 100644
index 000000000..88e3cdb87
--- /dev/null
+++ b/test/suite/intl402/ch10/10.3/10.3.2_CS_a.js
@@ -0,0 +1,56 @@
+// Copyright 2012 Norbert Lindenberg. All rights reserved.
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/**
+ * @description Tests that the function returned by Intl.Collator.prototype.compare
+ * returns 0 when comparing Strings that are considered canonically equivalent
+ * by the Unicode standard.
+ * @author Norbert Lindenberg
+ */
+
+var collator = new Intl.Collator();
+var pairs = [
+ // example from Unicode 5.0, section 3.7, definition D70
+ ["o\u0308", "ö"],
+ // examples from Unicode 5.0, chapter 3.11
+ ["ä\u0323", "a\u0323\u0308"],
+ ["a\u0308\u0323", "a\u0323\u0308"],
+ ["ạ\u0308", "a\u0323\u0308"],
+ ["ä\u0306", "a\u0308\u0306"],
+ ["ă\u0308", "a\u0306\u0308"],
+ // example from Unicode 5.0, chapter 3.12
+ ["\u1111\u1171\u11B6", "퓛"],
+ // examples from UTS 10, Unicode Collation Algorithm
+ ["Å", "Å"],
+ ["Å", "A\u030A"],
+ ["x\u031B\u0323", "x\u0323\u031B"],
+ ["ự", "ụ\u031B"],
+ ["ự", "u\u031B\u0323"],
+ ["ự", "ư\u0323"],
+ ["ự", "u\u0323\u031B"],
+ // examples from UAX 15, Unicode Normalization Forms
+ ["Ç", "C\u0327"],
+ ["q\u0307\u0323", "q\u0323\u0307"],
+ ["가", "\u1100\u1161"],
+ ["Å", "A\u030A"],
+ ["Ω", "Ω"],
+ ["Å", "A\u030A"],
+ ["ô", "o\u0302"],
+ ["ṩ", "s\u0323\u0307"],
+ ["ḋ\u0323", "d\u0323\u0307"],
+ ["ḋ\u0323", "ḍ\u0307"],
+ ["q\u0307\u0323", "q\u0323\u0307"],
+ // examples involving supplementary characters from UCD NormalizationTest.txt
+ ["\uD834\uDD5E", "\uD834\uDD57\uD834\uDD65"],
+ ["\uD87E\uDC2B", "北"]
+
+];
+var i;
+for (i = 0; i < pairs.length; i++) {
+ var pair = pairs[i];
+ if (collator.compare(pair[0], pair[1]) !== 0) {
+ $ERROR("Collator.compare considers " + pair[0] + " ≠ " + pair[1] + ".");
+ }
+}
+
diff --git a/test/suite/intl402/ch10/10.3/10.3.2_CS_b_NN.js b/test/suite/intl402/ch10/10.3/10.3.2_CS_b_NN.js
new file mode 100644
index 000000000..c417d2b8a
--- /dev/null
+++ b/test/suite/intl402/ch10/10.3/10.3.2_CS_b_NN.js
@@ -0,0 +1,22 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the compare function isn't entirely unreasonable.
+ * This test is not normative.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+// this test should be valid at least for the following locales
+var locales = ["de", "en", "es", "fr", "it"];
+locales = Intl.Collator.supportedLocalesOf(locales, {localeMatcher: "lookup"});
+locales.forEach(function (locale) {
+ var collator = new Intl.Collator([locale], {sensitivity: "variant", localeMatcher: "lookup"});
+ var a = ["L", "X", "C", "k", "Z", "H", "d", "m", "w", "A", "i", "f", "y", "E", "N", "V", "g", "J", "b"];
+ a.sort(collator.compare);
+ var expected = ["A", "b", "C", "d", "E", "f", "g", "H", "i", "J", "k", "L", "m", "N", "V", "w", "X", "y", "Z"];
+ testArraysAreSame(expected, a);
+});
+
diff --git a/test/suite/intl402/ch10/10.3/10.3.2_CS_c_NN.js b/test/suite/intl402/ch10/10.3/10.3.2_CS_c_NN.js
new file mode 100644
index 000000000..5d5060be5
--- /dev/null
+++ b/test/suite/intl402/ch10/10.3/10.3.2_CS_c_NN.js
@@ -0,0 +1,22 @@
+// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the compare function supports phonebook sorting if it says it does.
+ * This test is not normative.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+// this test should be valid at least for the following locales
+var locales = ["de-DE-u-co-phonebk", "de-u-co-phonebk"];
+var collator = new Intl.Collator(locales, {localeMatcher: "lookup"});
+if (locales.indexOf(collator.resolvedOptions().locale) !== -1) {
+ var a = ["A", "b", "Af", "Ab", "od", "off", "Ä", "ö"];
+ a.sort(collator.compare);
+ var expected = ["A", "Ab", "Ä", "Af", "b", "od", "ö", "off"];
+ testArraysAreSame(expected, a);
+}
+
diff --git a/test/suite/intl402/ch10/10.3/10.3.2_CS_d_NN.js b/test/suite/intl402/ch10/10.3/10.3.2_CS_d_NN.js
new file mode 100644
index 000000000..be5f1aa33
--- /dev/null
+++ b/test/suite/intl402/ch10/10.3/10.3.2_CS_d_NN.js
@@ -0,0 +1,34 @@
+// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the compare function supports different sensitivity settings.
+ * This test is not normative.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+// this test should be valid at least for the following locales
+var locales = ["de", "en", "es", "it"];
+locales = Intl.Collator.supportedLocalesOf(locales, {localeMatcher: "lookup"});
+locales.forEach(function (locale) {
+ var target = "Aa";
+ var input = ["Aa", "bA", "E", "b", "aA", "fC", "áÁ", "Aã"];
+ var expected = {
+ "base": ["Aa", "aA", "áÁ", "Aã"],
+ "accent": ["Aa", "aA"],
+ "case": ["Aa", "Aã"],
+ "variant": ["Aa"]
+ };
+ Object.getOwnPropertyNames(expected).forEach(function (sensitivity) {
+ var collator = new Intl.Collator([locale], {usage: "search",
+ sensitivity: sensitivity, localeMatcher: "lookup"});
+ var matches = input.filter(function (v) {
+ return collator.compare(v, target) === 0;
+ });
+ testArraysAreSame(expected[sensitivity], matches);
+ });
+});
+
diff --git a/test/suite/intl402/ch10/10.3/10.3.3.js b/test/suite/intl402/ch10/10.3/10.3.3.js
new file mode 100644
index 000000000..56c294491
--- /dev/null
+++ b/test/suite/intl402/ch10/10.3/10.3.3.js
@@ -0,0 +1,48 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/**
+ * @description Tests that the object returned by Intl.Collator.prototype.resolvedOptions
+ * has the right properties.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var actual = new Intl.Collator().resolvedOptions();
+
+var actual2 = new Intl.Collator().resolvedOptions();
+if (actual2 === actual) {
+ $ERROR("resolvedOptions returned the same object twice.");
+}
+
+// source: CLDR file common/bcp47/collation.xml; version CLDR 21.
+var collations = [
+ "default", // added
+ "big5han",
+ "dict",
+ "direct",
+ "ducet",
+ "gb2312",
+ "phonebk",
+ "phonetic",
+ "pinyin",
+ "reformed",
+ // "search", // excluded
+ "searchjl",
+ // "standard", // excluded
+ "stroke",
+ "trad",
+ "unihan"
+];
+
+// this assumes the default values where the specification provides them
+mustHaveProperty(actual, "locale", isCanonicalizedStructurallyValidLanguageTag);
+mustHaveProperty(actual, "usage", ["sort"]);
+mustHaveProperty(actual, "sensitivity", ["variant"]);
+mustHaveProperty(actual, "ignorePunctuation", [false]);
+mustHaveProperty(actual, "collation", collations);
+mayHaveProperty(actual, "numeric", [true, false]);
+mayHaveProperty(actual, "normalization", [true, false]);
+mayHaveProperty(actual, "caseFirst", ["upper", "lower", "false"]);
+
diff --git a/test/suite/intl402/ch10/10.3/10.3.js b/test/suite/intl402/ch10/10.3/10.3_a.js
index aa2e52845..aa2e52845 100644
--- a/test/suite/intl402/ch10/10.3/10.3.js
+++ b/test/suite/intl402/ch10/10.3/10.3_a.js
diff --git a/test/suite/intl402/ch10/10.3/10.3_b.js b/test/suite/intl402/ch10/10.3/10.3_b.js
new file mode 100644
index 000000000..9c3c2db32
--- /dev/null
+++ b/test/suite/intl402/ch10/10.3/10.3_b.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 Intl.Collator.prototype functions throw a
+ * TypeError if called on a non-object value or an object that hasn't been
+ * initialized as a Collator.
+ * @author Norbert Lindenberg
+ */
+
+var functions = {
+ "compare getter": Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get,
+ resolvedOptions: Intl.Collator.prototype.resolvedOptions
+};
+var invalidTargets = [undefined, null, true, 0, "Collator", [], {}];
+
+Object.getOwnPropertyNames(functions).forEach(function (functionName) {
+ var f = functions[functionName];
+ invalidTargets.forEach(function (target) {
+ var error;
+ try {
+ f.call(target);
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Calling " + functionName + " on " + target + " was not rejected.");
+ } else if (error.name !== "TypeError") {
+ $ERROR("Calling " + functionName + " on " + target + " was rejected with wrong error " + error.name + ".");
+ }
+ });
+});
+
diff --git a/test/suite/intl402/ch10/10.4/10.4_a.js b/test/suite/intl402/ch10/10.4/10.4_a.js
new file mode 100644
index 000000000..7527f65eb
--- /dev/null
+++ b/test/suite/intl402/ch10/10.4/10.4_a.js
@@ -0,0 +1,15 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that Intl.Collator instances have the specified properties.
+ * @author Norbert Lindenberg
+ */
+
+var obj = new Intl.Collator();
+
+var toStringValue = Object.prototype.toString.call(obj);
+if (toStringValue !== "[object Object]") {
+ $ERROR("Intl.Collator instance produces wrong [[Class]] - toString returns " + toStringValue + ".");
+}
+