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/ch09 | |
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/ch09')
24 files changed, 590 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/ch09/9.1/9.1_a.js b/js/src/tests/test262/intl402/ch09/9.1/9.1_a.js new file mode 100644 index 000000000..b7358304b --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.1/9.1_a.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 default locale is available. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testWithIntlConstructors(function (Constructor) { + var defaultLocale = new Constructor().resolvedOptions().locale; + var supportedLocales = Constructor.supportedLocalesOf([defaultLocale]); + if (supportedLocales.indexOf(defaultLocale) === -1) { + $ERROR("Default locale is not reported as available."); + } +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.1/9.1_b.js b/js/src/tests/test262/intl402/ch09/9.1/9.1_b.js new file mode 100644 index 000000000..a0abc7fc1 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.1/9.1_b.js @@ -0,0 +1,32 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that appropriate fallback locales are provided for + * supported locales. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testWithIntlConstructors(function (Constructor) { + var info = getLocaleSupportInfo(Constructor); + var fallback; + info.supported.forEach(function (locale) { + var pos = locale.lastIndexOf("-"); + if (pos !== -1) { + fallback = locale.substring(0, pos); + if (info.supported.indexOf(fallback) === -1) { + $ERROR("Locale " + locale + " is supported, but fallback " + fallback + " isn't."); + } + } + var match = /([a-z]{2,3})(-[A-Z][a-z]{3})(-[A-Z]{2})/.exec(locale); + if (match !== null) { + fallback = match[1] + match[3]; + if (info.supported.indexOf(fallback) === -1) { + $ERROR("Locale " + locale + " is supported, but fallback " + fallback + " isn't."); + } + } + }); +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.1/browser.js b/js/src/tests/test262/intl402/ch09/9.1/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.1/browser.js diff --git a/js/src/tests/test262/intl402/ch09/9.1/shell.js b/js/src/tests/test262/intl402/ch09/9.1/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.1/shell.js diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.1_1.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_1.js new file mode 100644 index 000000000..7386fdeda --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_1.js @@ -0,0 +1,23 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that canonicalization of locale lists treats undefined and empty lists the same. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testWithIntlConstructors(function (Constructor) { + var supportedForUndefined = Constructor.supportedLocalesOf(undefined); + var supportedForEmptyList = Constructor.supportedLocalesOf([]); + if (supportedForUndefined.length !== supportedForEmptyList.length) { + $ERROR("Supported locales differ between undefined and empty list input."); + } + // we don't compare the elements because length should be 0 - let's just verify that + if (supportedForUndefined.length !== 0) { + $ERROR("Internal test error: Assumption about length being 0 is invalid."); + } + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.1_2.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_2.js new file mode 100644 index 000000000..e4fb3756d --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_2.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 the behavior of a List is not affected by adversarial + * changes to Array.prototype. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +taintArray(); + +testWithIntlConstructors(function (Constructor) { + var defaultLocale = new Constructor().resolvedOptions().locale; + var canonicalized = Constructor.supportedLocalesOf([defaultLocale, defaultLocale]); + if (canonicalized.length > 1) { + $ERROR("Canonicalization didn't remove duplicate language tags from locale list."); + } +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.1_3.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_3.js new file mode 100644 index 000000000..e403b1765 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_3.js @@ -0,0 +1,87 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that a single string instead of a locale list is treated + * as the locale list containing that string. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +var validAndInvalidLanguageTags = [ + "de", // ISO 639 language code + "de-DE", // + ISO 3166-1 country code + "DE-de", // tags are case-insensitive + "cmn", // ISO 639 language code + "cmn-Hans", // + script code + "CMN-hANS", // tags are case-insensitive + "cmn-hans-cn", // + ISO 3166-1 country code + "es-419", // + UN M.49 region code + "es-419-u-nu-latn-cu-bob", // + Unicode locale extension sequence + "i-klingon", // grandfathered tag + "cmn-hans-cn-t-ca-u-ca-x-t-u", // singleton subtags can also be used as private use subtags + "enochian-enochian", // language and variant subtags may be the same + "de-gregory-u-ca-gregory", // variant and extension subtags may be the same + "de_DE", + "DE_de", + "cmn_Hans", + "cmn-hans_cn", + "es_419", + "es-419-u-nu-latn-cu_bob", + "i_klingon", + "cmn-hans-cn-t-ca-u-ca-x_t-u", + "enochian_enochian", + "de-gregory_u-ca-gregory", + "i", // singleton alone + "x", // private use without subtag + "u", // extension singleton in first place + "419", // region code in first place + "u-nu-latn-cu-bob", // extension sequence without language + "hans-cmn-cn", // "hans" could theoretically be a 4-letter language code, + // but those can't be followed by extlang codes. + "cmn-hans-cn-u-u", // duplicate singleton + "cmn-hans-cn-t-u-ca-u", // duplicate singleton + "de-gregory-gregory" // duplicate variant +]; + +testWithIntlConstructors(function (Constructor) { + validAndInvalidLanguageTags.forEach(function (locale) { + var obj1, obj2, locale1, locale2, error1, error2; + try { + obj1 = new Constructor(locale); + locale1 = obj1.resolvedOptions().locale; + } catch (e) { + error1 = e; + } + try { + obj2 = new Constructor([locale]); + locale2 = obj2.resolvedOptions().locale; + } catch (e) { + error2 = e; + } + + if ((error1 === undefined) !== (error2 === undefined)) { + if (error1 === undefined) { + $ERROR("Single locale string " + locale + + " was accepted, but locale list containing that string wasn't."); + } else { + $ERROR("Single locale string " + locale + + " was rejected, but locale list containing that string wasn't."); + } + } else if (error1 === undefined) { + if (locale1 !== locale2) { + $ERROR("Single locale string " + locale + " results in " + locale1 + + ", but locale list [" + locale + "] results in " + locale2 + "."); + } + } else { + if (error1.name !== error2.name) { + $ERROR("Single locale string " + locale + " results in error " + error1.name + + ", but locale list [" + locale + "] results in error " + error2.name + "."); + } + } + }); + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.1_4.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_4.js new file mode 100644 index 000000000..b9bb9db79 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_4.js @@ -0,0 +1,46 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that non-objects are converted to objects before canonicalization. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testWithIntlConstructors(function (Constructor) { + // undefined is handled separately + + // null should result in a TypeError + var error; + try { + var supportedForNull = Constructor.supportedLocalesOf(null); + } catch (e) { + error = e; + } + if (error === undefined) { + $ERROR("Null as locale list was not rejected."); + } else if (error.name !== "TypeError") { + $ERROR("Null as locale list was rejected with wrong error " + error.name + "."); + } + + // let's use an empty list for comparison + var supportedForEmptyList = Constructor.supportedLocalesOf([]); + // we don't compare the elements because length should be 0 - let's just verify that + if (supportedForEmptyList.length !== 0) { + $ERROR("Internal test error: Assumption about length being 0 is invalid."); + } + + // most non-objects will be interpreted as empty lists because a missing length property is interpreted as 0 + var supportedForNumber = Constructor.supportedLocalesOf(5); + if (supportedForNumber.length !== supportedForEmptyList.length) { + $ERROR("Supported locales differ between numeric and empty list input."); + } + var supportedForBoolean = Constructor.supportedLocalesOf(true); + if (supportedForBoolean.length !== supportedForEmptyList.length) { + $ERROR("Supported locales differ between boolean and empty list input."); + } + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.1_8_c_ii.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_8_c_ii.js new file mode 100644 index 000000000..8dfb9b7b3 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_8_c_ii.js @@ -0,0 +1,30 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that values other than strings are not accepted as locales. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +var notStringOrObject = [undefined, null, true, false, 0, 5, -5, NaN]; + +testWithIntlConstructors(function (Constructor) { + notStringOrObject.forEach(function (value) { + var error; + try { + var supported = Constructor.supportedLocalesOf([value]); + } catch (e) { + error = e; + } + if (error === undefined) { + $ERROR("" + value + " as locale was not rejected."); + } else if (error.name !== "TypeError") { + $ERROR("" + value + " as locale was rejected with wrong error " + error.name + "."); + } + }); + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.1_8_c_vi.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_8_c_vi.js new file mode 100644 index 000000000..ef78fa97b --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.1_8_c_vi.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 canonicalization of locale lists removes duplicate language tags. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testWithIntlConstructors(function (Constructor) { + var defaultLocale = new Constructor().resolvedOptions().locale; + var canonicalized = Constructor.supportedLocalesOf([defaultLocale, defaultLocale]); + if (canonicalized.length > 1) { + $ERROR("Canonicalization didn't remove duplicate language tags from locale list."); + } +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.2.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.2.js new file mode 100644 index 000000000..cb74eaad2 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.2.js @@ -0,0 +1,45 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that locales that are reported by resolvedOptions + * are also reported by supportedLocalesOf. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testWithIntlConstructors(function (Constructor) { + var info = getLocaleSupportInfo(Constructor); + // this test should work equally for both matching algorithms + ["lookup", "best fit"].forEach(function (matcher) { + var supportedByConstructor = info.supported.concat(info.byFallback); + var supported = Constructor.supportedLocalesOf(supportedByConstructor, + {localeMatcher: matcher}); + // we could check the length first, but it's probably more interesting which locales are missing + var i = 0; + var limit = Math.min(supportedByConstructor.length, supported.length); + while (i < limit && supportedByConstructor[i] === supported[i]) { + i++; + } + if (i < supportedByConstructor.length) { + $ERROR("Locale " + supportedByConstructor[i] + + " is returned by resolvedOptions but not by supportedLocalesOf."); + } else if (i < supported.length) { + $ERROR("Locale " + supported[i] + + " is returned by supportedLocalesOf but not by resolvedOptions."); + } + }); + + // this test is only valid for lookup - best fit may find additional locales supported + var unsupportedByConstructor = info.unsupported; + var supported = Constructor.supportedLocalesOf(unsupportedByConstructor, + {localeMatcher: "lookup"}); + if (supported.length > 0) { + $ERROR("Locale " + supported[0] + + " is returned by supportedLocalesOf but not by resolvedOptions."); + } + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.3_5.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.3_5.js new file mode 100644 index 000000000..8ae8a216b --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.3_5.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 behavior of a Record is not affected by adversarial + * changes to Object.prototype. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +taintProperties(["locale", "extension", "extensionIndex"]); + +testWithIntlConstructors(function (Constructor) { + var locale = new Constructor(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale; + if (!isCanonicalizedStructurallyValidLanguageTag(locale)) { + $ERROR("Constructor returns invalid locale " + locale + "."); + } + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.5_11_g_ii_2.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.5_11_g_ii_2.js new file mode 100644 index 000000000..d4213d2da --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.5_11_g_ii_2.js @@ -0,0 +1,26 @@ +// 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 missing Unicode extension values default to true for + * boolean keys. + * @author Norbert Lindenberg + */ + +var extensions = ["-u-co-phonebk-kn", "-u-kn-co-phonebk"]; +extensions.forEach(function (extension) { + var defaultLocale = new Intl.Collator().resolvedOptions().locale; + var collator = new Intl.Collator([defaultLocale + extension], {usage: "sort"}); + var locale = collator.resolvedOptions().locale; + var numeric = collator.resolvedOptions().numeric; + if (numeric !== undefined) { + if (numeric !== true) { + $ERROR("Default value for \"kn\" should be true, but is " + numeric + "."); + } + if (locale.indexOf("-kn") !== -1) { + $ERROR("\"kn\" is returned in locale, but shouldn't be."); + } + } +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.5_6.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.5_6.js new file mode 100644 index 000000000..4bc904ee1 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.5_6.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 behavior of a Record is not affected by adversarial + * changes to Object.prototype. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +taintProperties(["dataLocale", "nu", "ca", "co", "locale"]); + +testWithIntlConstructors(function (Constructor) { + var locale = new Constructor(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale; + if (!isCanonicalizedStructurallyValidLanguageTag(locale)) { + $ERROR("Constructor returns invalid locale " + locale + "."); + } + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.6_2.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.6_2.js new file mode 100644 index 000000000..8d4f7efa9 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.6_2.js @@ -0,0 +1,27 @@ +// 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 List is not affected by adversarial + * changes to Array.prototype. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +taintArray(); + +testWithIntlConstructors(function (Constructor) { + // this test should work equally for both matching algorithms + ["lookup", "best fit"].forEach(function (matcher) { + var defaultLocale = new Constructor().resolvedOptions().locale; + var canonicalized = Constructor.supportedLocalesOf([defaultLocale, defaultLocale], + {localeMatcher: matcher}); + if (canonicalized.length > 1) { + $ERROR("Canonicalization with matcher " + matcher + " didn't remove duplicate language tags from locale list."); + } + }); + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.6_4.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.6_4.js new file mode 100644 index 000000000..7c053a381 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.6_4.js @@ -0,0 +1,23 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that LookupSupportedLocales returns an empty list when + * given an empty list. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testWithIntlConstructors(function (Constructor) { + // this test should work equally for both matching algorithms + ["lookup", "best fit"].forEach(function (matcher) { + var supported = Constructor.supportedLocalesOf([], {localeMatcher: matcher}); + if (supported.length !== 0) { + $ERROR("SupportedLocales with matcher " + matcher + " returned a non-empty list for an empty list."); + } + }); + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.6_4_b.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.6_4_b.js new file mode 100644 index 000000000..5b9a43157 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.6_4_b.js @@ -0,0 +1,47 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that Unicode locale extension sequences do not affect + * whether a locale is considered supported, but are reported back. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testWithIntlConstructors(function (Constructor) { + // this test should work equally for both matching algorithms + ["lookup", "best fit"].forEach(function (matcher) { + var info = getLocaleSupportInfo(Constructor); + var allLocales = info.supported.concat(info.byFallback, info.unsupported); + allLocales.forEach(function (locale) { + var validExtension = "-u-co-phonebk-nu-latn"; + var invalidExtension = "-u-nu-invalid"; + var supported1 = Constructor.supportedLocalesOf([locale], + {localeMatcher: matcher}); + var supported2 = Constructor.supportedLocalesOf([locale + validExtension], + {localeMatcher: matcher}); + var supported3 = Constructor.supportedLocalesOf([locale + invalidExtension], + {localeMatcher: matcher}); + if (supported1.length === 1) { + if (supported2.length !== 1 || supported3.length !== 1) { + $ERROR("Presence of Unicode locale extension sequence affects whether locale " + + locale + " is considered supported with matcher " + matcher + "."); + } + if (supported2[0] !== locale + validExtension || supported3[0] !== locale + invalidExtension) { + alert(locale + "; " + supported2[0] + "; " + supported3[0]); + $ERROR("Unicode locale extension sequence is not correctly returned for locale " + + locale + " with matcher " + matcher + "."); + } + } else { + if (supported2.length !== 0 || supported3.length !== 0) { + $ERROR("Presence of Unicode locale extension sequence affects whether locale " + + locale + " is considered supported with matcher " + matcher + "."); + } + } + }); + }); + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.6_4_c.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.6_4_c.js new file mode 100644 index 000000000..de68a9b66 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.6_4_c.js @@ -0,0 +1,32 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that LookupSupportedLocales includes the default locale + * and doesn't include the "no linguistic content" locale. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testWithIntlConstructors(function (Constructor) { + // this test should work equally for both matching algorithms + ["lookup", "best fit"].forEach(function (matcher) { + var defaultLocale = new Constructor().resolvedOptions().locale; + var noLinguisticContent = "zxx"; + var supported = Constructor.supportedLocalesOf([defaultLocale, noLinguisticContent], + {localeMatcher: matcher}); + if (supported.indexOf(defaultLocale) === -1) { + $ERROR("SupportedLocales didn't return default locale with matcher " + matcher + "."); + } + if (supported.indexOf(noLinguisticContent) !== -1) { + $ERROR("SupportedLocales returned the \"no linguistic content\" locale with matcher " + matcher + "."); + } + if (supported.length > 1) { + $ERROR("SupportedLocales returned stray locales: " + supported.join(", ") + " with matcher " + matcher + "."); + } + }); + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.8_1_c.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.8_1_c.js new file mode 100644 index 000000000..724db1edd --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.8_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 the option localeMatcher is processed correctly. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +testWithIntlConstructors(function (Constructor) { + var defaultLocale = new Constructor().resolvedOptions().locale; + + var validValues = [undefined, "lookup", "best fit", {toString: function () { return "lookup"; }}]; + validValues.forEach(function (value) { + var supported = Constructor.supportedLocalesOf([defaultLocale], {localeMatcher: value}); + }); + + var invalidValues = [null, 0, 5, NaN, true, false, "invalid"]; + invalidValues.forEach(function (value) { + var error; + try { + var supported = Constructor.supportedLocalesOf([defaultLocale], {localeMatcher: value}); + } catch (e) { + error = e; + } + if (error === undefined) { + $ERROR("Invalid localeMatcher value " + value + " was not rejected."); + } else if (error.name !== "RangeError") { + $ERROR("Invalid localeMatcher value " + value + " was rejected with wrong error " + error.name + "."); + } + }); + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/9.2.8_4.js b/js/src/tests/test262/intl402/ch09/9.2/9.2.8_4.js new file mode 100644 index 000000000..79c362f62 --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.8_4.js @@ -0,0 +1,35 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that the array returned by SupportedLocales is extensible, + * but its properties are non-writable/non-configurable. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +function testFrozenProperty(obj, property) { + var desc = Object.getOwnPropertyDescriptor(obj, property); + if (desc.writable) { + $ERROR("Property " + property + " of object returned by SupportedLocales is writable."); + } + if (desc.configurable) { + $ERROR("Property " + property + " of object returned by SupportedLocales is configurable."); + } +} + +testWithIntlConstructors(function (Constructor) { + var defaultLocale = new Constructor().resolvedOptions().locale; + var supported = Constructor.supportedLocalesOf([defaultLocale]); + if (!Object.isExtensible(supported)) { + $ERROR("Object returned by SupportedLocales is not extensible."); + } + for (var i = 0; i < supported.length; i++) { + testFrozenProperty(supported, i); + } + testFrozenProperty(supported, "length"); + + return true; +}); + diff --git a/js/src/tests/test262/intl402/ch09/9.2/browser.js b/js/src/tests/test262/intl402/ch09/9.2/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/browser.js diff --git a/js/src/tests/test262/intl402/ch09/9.2/shell.js b/js/src/tests/test262/intl402/ch09/9.2/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/9.2/shell.js diff --git a/js/src/tests/test262/intl402/ch09/browser.js b/js/src/tests/test262/intl402/ch09/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/browser.js diff --git a/js/src/tests/test262/intl402/ch09/shell.js b/js/src/tests/test262/intl402/ch09/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch09/shell.js |