summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/ch06/6.2
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/test262/intl402/ch06/6.2
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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/ch06/6.2')
-rw-r--r--js/src/tests/test262/intl402/ch06/6.2/6.2.2_a.js40
-rw-r--r--js/src/tests/test262/intl402/ch06/6.2/6.2.2_b.js41
-rw-r--r--js/src/tests/test262/intl402/ch06/6.2/6.2.2_c.js47
-rw-r--r--js/src/tests/test262/intl402/ch06/6.2/6.2.3.js69
-rw-r--r--js/src/tests/test262/intl402/ch06/6.2/6.2.4.js19
-rw-r--r--js/src/tests/test262/intl402/ch06/6.2/browser.js0
-rw-r--r--js/src/tests/test262/intl402/ch06/6.2/shell.js0
7 files changed, 216 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/ch06/6.2/6.2.2_a.js b/js/src/tests/test262/intl402/ch06/6.2/6.2.2_a.js
new file mode 100644
index 000000000..a56894570
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch06/6.2/6.2.2_a.js
@@ -0,0 +1,40 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that structurally valid language tags are accepted.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var validLanguageTags = [
+ "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
+ "aa-a-foo-x-a-foo-bar", // variant subtags can also be used as private use subtags
+ "x-en-US-12345", // anything goes in private use tags
+ "x-12345-12345-en-US",
+ "x-en-US-12345-12345",
+ "x-en-u-foo",
+ "x-en-u-foo-u-bar"
+];
+
+testWithIntlConstructors(function (Constructor) {
+ validLanguageTags.forEach(function (tag) {
+ // this must not throw an exception for a valid language tag
+ var obj = new Constructor([tag]);
+ });
+ return true;
+});
+
diff --git a/js/src/tests/test262/intl402/ch06/6.2/6.2.2_b.js b/js/src/tests/test262/intl402/ch06/6.2/6.2.2_b.js
new file mode 100644
index 000000000..42d69e7c2
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch06/6.2/6.2.2_b.js
@@ -0,0 +1,41 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that language tags with "_" are not accepted.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var invalidLanguageTags = [
+ "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"
+];
+
+testWithIntlConstructors(function (Constructor) {
+ invalidLanguageTags.forEach(function (tag) {
+ var error;
+ try {
+ // this must throw an exception for an invalid language tag
+ var obj = new Constructor([tag]);
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Invalid language tag " + tag + " was not rejected.");
+ } else if (error.name !== "RangeError") {
+ $ERROR("Invalid language tag " + tag + " was rejected with wrong error " + error.name + ".");
+ }
+ });
+ return true;
+});
+
diff --git a/js/src/tests/test262/intl402/ch06/6.2/6.2.2_c.js b/js/src/tests/test262/intl402/ch06/6.2/6.2.2_c.js
new file mode 100644
index 000000000..6d669ebef
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch06/6.2/6.2.2_c.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 language tags with invalid subtag sequences are not accepted.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var invalidLanguageTags = [
+ "", // empty tag
+ "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
+ "*", // language range
+ "de-*", // language range
+ "中文", // non-ASCII letters
+ "en-ß", // non-ASCII letters
+ "ıd" // non-ASCII letters
+];
+
+testWithIntlConstructors(function (Constructor) {
+ invalidLanguageTags.forEach(function (tag) {
+ var error;
+ try {
+ // this must throw an exception for an invalid language tag
+ var obj = new Constructor([tag]);
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Invalid language tag " + tag + " was not rejected.");
+ } else if (error.name !== "RangeError") {
+ $ERROR("Invalid language tag " + tag + " was rejected with wrong error " + error.name + ".");
+ }
+ });
+ return true;
+});
+
diff --git a/js/src/tests/test262/intl402/ch06/6.2/6.2.3.js b/js/src/tests/test262/intl402/ch06/6.2/6.2.3.js
new file mode 100644
index 000000000..4ae15ab27
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch06/6.2/6.2.3.js
@@ -0,0 +1,69 @@
+// 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 language tags are canonicalized in return values.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var canonicalizedTags = {
+ "de": ["de"],
+ "de-DE": ["de-DE", "de"],
+ "DE-de": ["de-DE", "de"],
+ "cmn": ["cmn"],
+ "CMN-hANS": ["cmn-Hans", "cmn"],
+ "cmn-hans-cn": ["cmn-Hans-CN", "cmn-Hans", "cmn"],
+ "es-419": ["es-419", "es"],
+ "es-419-u-nu-latn": ["es-419-u-nu-latn", "es-419", "es", "es-u-nu-latn"],
+ // -u-ca is incomplete, so it will not show up in resolvedOptions().locale
+ "cmn-hans-cn-u-ca-t-ca-x-t-u": ["cmn-Hans-CN-t-ca-u-ca-x-t-u", "cmn-Hans-CN-t-ca-x-t-u", "cmn-Hans-CN-t-ca-x-t", "cmn-Hans-CN-t-ca", "cmn-Hans-CN", "cmn-Hans", "cmn"],
+ "enochian-enochian": ["enochian-enochian", "enochian"],
+ "de-gregory-u-ca-gregory": ["de-gregory-u-ca-gregory", "de-gregory", "de-u-ca-gregory", "de"],
+ "no-nyn": ["nn"],
+ "i-klingon": ["tlh"],
+ "sgn-GR": ["gss"],
+ "ji": ["yi"],
+ "de-DD": ["de-DE", "de"],
+ "zh-hak-CN": ["hak-CN", "hak"],
+ "sgn-ils": ["ils"],
+ "in": ["id"],
+ "x-foo": ["x-foo"]
+};
+
+// make sure the data above is correct
+Object.getOwnPropertyNames(canonicalizedTags).forEach(function (tag) {
+ canonicalizedTags[tag].forEach(function (canonicalTag) {
+ if (!isCanonicalizedStructurallyValidLanguageTag(canonicalTag)) {
+ $ERROR("Test data \"" + canonicalTag + "\" is not canonicalized and structurally valid language tag.");
+ }
+ });
+});
+
+// now the actual test
+testWithIntlConstructors(function (Constructor) {
+ var defaultLocale = new Constructor().resolvedOptions().locale;
+ Object.getOwnPropertyNames(canonicalizedTags).forEach(function (tag) {
+ // use lookup locale matcher to keep the set of possible return values predictable
+
+ // Variant 1: construct an object and see whether its locale is canonicalized.
+ // In this variant, shortened forms or the default locale may be returned
+ var object = new Constructor([tag], {localeMatcher: "lookup"});
+ var locale = object.resolvedOptions().locale;
+ if (canonicalizedTags[tag].indexOf(locale) === -1 && locale !== defaultLocale) {
+ $ERROR("For " + tag + " got " + locale + "; expected one of " +
+ canonicalizedTags[tag].join(", ") + ".");
+ }
+
+ // Variant 2: get the supported locales. If the tag is supported, it should be returned canonicalized but unshortened
+ var supported = Constructor.supportedLocalesOf([tag]);
+ if (supported.length > 0 && supported[0] !== canonicalizedTags[tag][0]) {
+ $ERROR("For " + tag + " got " + supported[0] + "; expected " +
+ canonicalizedTags[tag][0] + ".");
+ }
+ });
+ return true;
+});
+
diff --git a/js/src/tests/test262/intl402/ch06/6.2/6.2.4.js b/js/src/tests/test262/intl402/ch06/6.2/6.2.4.js
new file mode 100644
index 000000000..6ca47af14
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch06/6.2/6.2.4.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 the default locale is a String value representing the
+ * structurally valid and canonicalized BCP 47 language tag.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testWithIntlConstructors(function (Constructor) {
+ var defaultLocale = new Constructor().resolvedOptions().locale;
+ if (!isCanonicalizedStructurallyValidLanguageTag(defaultLocale)) {
+ $ERROR("Default locale \"" + defaultLocale + "\" is not canonicalized and structurally valid language tag.");
+ }
+ return true;
+});
+
diff --git a/js/src/tests/test262/intl402/ch06/6.2/browser.js b/js/src/tests/test262/intl402/ch06/6.2/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch06/6.2/browser.js
diff --git a/js/src/tests/test262/intl402/ch06/6.2/shell.js b/js/src/tests/test262/intl402/ch06/6.2/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch06/6.2/shell.js