diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/test262/intl402/ch10/10.3 | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/test262/intl402/ch10/10.3')
15 files changed, 346 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/ch10/10.3/10.3.1.js b/js/src/tests/test262/intl402/ch10/10.3/10.3.1.js new file mode 100644 index 000000000..699949e18 --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.3/10.3.1.js @@ -0,0 +1,13 @@ +// Copyright 2012 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that Intl.Collator.prototype.constructor is the + * Intl.Collator. + */ + +if (Intl.Collator.prototype.constructor !== Intl.Collator) { + $ERROR("Intl.Collator.prototype.constructor is not the same as " + + "Intl.Collator"); +} + diff --git a/js/src/tests/test262/intl402/ch10/10.3/10.3.2_1_a_L15.js b/js/src/tests/test262/intl402/ch10/10.3/10.3.2_1_a_L15.js new file mode 100644 index 000000000..3d49601db --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.3/10.3.2_1_a_L15.js @@ -0,0 +1,14 @@ +// 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 + * meets the requirements for built-in objects defined by the introduction of + * chapter 15 of the ECMAScript Language Specification. + * @author Norbert Lindenberg + */ + +$INCLUDE("testBuiltInObject.js"); + +testBuiltInObject(new Intl.Collator().compare, true, false, [], 2); + diff --git a/js/src/tests/test262/intl402/ch10/10.3/10.3.2_1_c.js b/js/src/tests/test262/intl402/ch10/10.3/10.3.2_1_c.js new file mode 100644 index 000000000..73f2bcf09 --- /dev/null +++ b/js/src/tests/test262/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.", "𠮷野家", "吉野家", "!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/js/src/tests/test262/intl402/ch10/10.3/10.3.2_CS_a.js b/js/src/tests/test262/intl402/ch10/10.3/10.3.2_CS_a.js new file mode 100644 index 000000000..a946245b4 --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.3/10.3.2_CS_a.js @@ -0,0 +1,68 @@ +// 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] + " (" + toU(pair[0]) + + ") ≠ " + pair[1] + " (" + toU(pair[1]) + ")."); + } +} + +function toU(s) { + var result = ""; + var escape = "\\u0000"; + var i; + for (i = 0; i < s.length; i++) { + var hex = s.charCodeAt(i).toString(16); + result += escape.substring(0, escape.length - hex.length) + hex; + } + return result; +} + diff --git a/js/src/tests/test262/intl402/ch10/10.3/10.3.2_CS_b_NN.js b/js/src/tests/test262/intl402/ch10/10.3/10.3.2_CS_b_NN.js new file mode 100644 index 000000000..c417d2b8a --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.3/10.3.2_CS_c_NN.js b/js/src/tests/test262/intl402/ch10/10.3/10.3.2_CS_c_NN.js new file mode 100644 index 000000000..5d5060be5 --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.3/10.3.2_CS_d_NN.js b/js/src/tests/test262/intl402/ch10/10.3/10.3.2_CS_d_NN.js new file mode 100644 index 000000000..be5f1aa33 --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.3/10.3.2_L15.js b/js/src/tests/test262/intl402/ch10/10.3/10.3.2_L15.js new file mode 100644 index 000000000..5845ea3ca --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.3/10.3.2_L15.js @@ -0,0 +1,14 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/** + * @description Tests that the getter for Intl.Collator.prototype.compare + * meets the requirements for built-in objects defined by the introduction of + * chapter 15 of the ECMAScript Language Specification. + * @author Norbert Lindenberg + */ + +$INCLUDE("testBuiltInObject.js"); + +testBuiltInObject(Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get , true, false, [], 0); + diff --git a/js/src/tests/test262/intl402/ch10/10.3/10.3.3.js b/js/src/tests/test262/intl402/ch10/10.3/10.3.3.js new file mode 100644 index 000000000..bc6b4fabb --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.3/10.3.3.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 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, "caseFirst", ["upper", "lower", "false"]); + diff --git a/js/src/tests/test262/intl402/ch10/10.3/10.3.3_L15.js b/js/src/tests/test262/intl402/ch10/10.3/10.3.3_L15.js new file mode 100644 index 000000000..718cc9fea --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.3/10.3.3_L15.js @@ -0,0 +1,14 @@ +// 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.resolvedOptions + * meets the requirements for built-in objects defined by the introduction of + * chapter 15 of the ECMAScript Language Specification. + * @author Norbert Lindenberg + */ + +$INCLUDE("testBuiltInObject.js"); + +testBuiltInObject(Intl.Collator.prototype.resolvedOptions, true, false, [], 0); + diff --git a/js/src/tests/test262/intl402/ch10/10.3/10.3_L15.js b/js/src/tests/test262/intl402/ch10/10.3/10.3_L15.js new file mode 100644 index 000000000..60719736c --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.3/10.3_L15.js @@ -0,0 +1,14 @@ +// 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 + * meets the requirements for built-in objects defined by the introduction of + * chapter 15 of the ECMAScript Language Specification. + * @author Norbert Lindenberg + */ + +$INCLUDE("testBuiltInObject.js"); + +testBuiltInObject(Intl.Collator.prototype, false, false, ["constructor", "compare", "resolvedOptions"]); + diff --git a/js/src/tests/test262/intl402/ch10/10.3/10.3_a.js b/js/src/tests/test262/intl402/ch10/10.3/10.3_a.js new file mode 100644 index 000000000..aa2e52845 --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.3/10.3_a.js @@ -0,0 +1,15 @@ +// Copyright 2012 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that Intl.Collator.prototype is an object that + * has been initialized as an Intl.Collator. + */ + +// test by calling a function that would fail if "this" were not an object +// initialized as an Intl.Collator +if (Intl.Collator.prototype.compare("aаあ아", "aаあ아") !== 0) { + $ERROR("Intl.Collator.prototype is not an object that has been " + + "initialized as an Intl.Collator."); +} + diff --git a/js/src/tests/test262/intl402/ch10/10.3/10.3_b.js b/js/src/tests/test262/intl402/ch10/10.3/10.3_b.js new file mode 100644 index 000000000..9c3c2db32 --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.3/browser.js b/js/src/tests/test262/intl402/ch10/10.3/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.3/browser.js diff --git a/js/src/tests/test262/intl402/ch10/10.3/shell.js b/js/src/tests/test262/intl402/ch10/10.3/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.3/shell.js |