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.1 | |
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.1')
16 files changed, 329 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/ch10/10.1/10.1.1_1.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_1.js new file mode 100644 index 000000000..432e073fc --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.1/10.1.1_10.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_10.js new file mode 100644 index 000000000..5c6b657b5 --- /dev/null +++ b/js/src/tests/test262/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", "kf"]); + +var locale = new Intl.Collator(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale; +if (!isCanonicalizedStructurallyValidLanguageTag(locale)) { + $ERROR("Collator returns invalid locale " + locale + "."); +} + diff --git a/js/src/tests/test262/intl402/ch10/10.1/10.1.1_11.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_11.js new file mode 100644 index 000000000..447fd8b28 --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.1/10.1.1_13.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_13.js new file mode 100644 index 000000000..4129eebd2 --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_13.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 options numeric and caseFirst are processed correctly. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testOption(Intl.Collator, "numeric", "boolean", undefined, undefined, {isOptional: true}); +testOption(Intl.Collator, "caseFirst", "string", ["upper", "lower", "false"], undefined, {isOptional: true}); + diff --git a/js/src/tests/test262/intl402/ch10/10.1/10.1.1_19_b.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_19_b.js new file mode 100644 index 000000000..f1fef2704 --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.1/10.1.1_19_c.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_19_c.js new file mode 100644 index 000000000..4ad76d45b --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_19_c.js @@ -0,0 +1,63 @@ +// 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 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: "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/js/src/tests/test262/intl402/ch10/10.1/10.1.1_20.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_20.js new file mode 100644 index 000000000..97d70c0f9 --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.1/10.1.1_23.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_23.js new file mode 100644 index 000000000..0b5261509 --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.1/10.1.1_6.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_6.js new file mode 100644 index 000000000..bc13436d7 --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.1/10.1.1_a.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_a.js new file mode 100644 index 000000000..56d4b9789 --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_a.js @@ -0,0 +1,14 @@ +// Copyright 2013 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that constructing a Collator doesn't create or modify + * unwanted properties on the RegExp constructor. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testForUnwantedRegExpChanges(function () { + new Intl.Collator("de-DE-u-co-phonebk"); +}); diff --git a/js/src/tests/test262/intl402/ch10/10.1/10.1.2.1_4.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.2.1_4.js new file mode 100644 index 000000000..22e69065e --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.1/10.1.2.1_4.js @@ -0,0 +1,21 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that for non-object values passed as this to Collator a + * wrapper object will be initialized and returned. + * @author Norbert Lindenberg + */ + +var thisValues = [true, 42, "国際化"]; + +thisValues.forEach(function (value) { + var collator = Intl.Collator.call(value); + // check that the returned object functions as a collator + var referenceCollator = new Intl.Collator(); + if (Intl.Collator.prototype.compare.call(collator, "a", "b") !== referenceCollator.compare("a", "b")) { + $ERROR("Collator initialized from " + value + " doesn't behave like normal collator."); + } + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch10/10.1/10.1.2_a.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.2_a.js new file mode 100644 index 000000000..de69a4809 --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.1/10.1.3.js b/js/src/tests/test262/intl402/ch10/10.1/10.1.3.js new file mode 100644 index 000000000..7459d98d6 --- /dev/null +++ b/js/src/tests/test262/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/js/src/tests/test262/intl402/ch10/10.1/10.1_L15.js b/js/src/tests/test262/intl402/ch10/10.1/10.1_L15.js new file mode 100644 index 000000000..4dbabfd64 --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.1/10.1_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 + * 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, true, true, ["supportedLocalesOf"], 0); + diff --git a/js/src/tests/test262/intl402/ch10/10.1/browser.js b/js/src/tests/test262/intl402/ch10/10.1/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.1/browser.js diff --git a/js/src/tests/test262/intl402/ch10/10.1/shell.js b/js/src/tests/test262/intl402/ch10/10.1/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch10/10.1/shell.js |