diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/Intl/legacy-and-sign-locales-with-unicode-extensions.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/tests/non262/Intl/legacy-and-sign-locales-with-unicode-extensions.js | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/js/src/tests/non262/Intl/legacy-and-sign-locales-with-unicode-extensions.js b/js/src/tests/non262/Intl/legacy-and-sign-locales-with-unicode-extensions.js new file mode 100644 index 0000000000..2421d9bb09 --- /dev/null +++ b/js/src/tests/non262/Intl/legacy-and-sign-locales-with-unicode-extensions.js @@ -0,0 +1,79 @@ +// |reftest| skip-if(!this.hasOwnProperty("Intl")) + +const languageTags = { + // Case 1: legacy, regular tags. + "art-lojban": "jbo", + "cel-gaulish": "xtg", + "zh-guoyu": "zh", + "zh-hakka": "hak", + "zh-xiang": "hsn", + + // Case 2: redundant language tags. + "sgn-BR": "bzs", + "sgn-CO": "csn", + "sgn-DE": "gsg", + "sgn-DK": "dsl", + "sgn-ES": "ssp", + "sgn-FR": "fsl", + "sgn-GB": "bfi", + "sgn-GR": "gss", + "sgn-IE": "isg", + "sgn-IT": "ise", + "sgn-JP": "jsl", + "sgn-MX": "mfs", + "sgn-NI": "ncs", + "sgn-NL": "dse", + "sgn-NO": "nsi", + "sgn-PT": "psr", + "sgn-SE": "swl", + "sgn-US": "ase", + "sgn-ZA": "sfs", + + // Case 3: the special case. + "ja-Latn-hepburn-heploc": "ja-Latn-alalc97", +}; +const extensions = ["-u-attr", "-u-nu-latn"]; +const intlConstructors = [Intl.Collator, Intl.DateTimeFormat, Intl.NumberFormat]; +const options = [{localeMatcher: "best fit"}, {localeMatcher: "lookup"}]; + +for (let [tag, canonical] of Object.entries(languageTags)) { + // Ensure Intl.getCanonicalLocales canonicalizes the language tag correctly. + assertEq(Intl.getCanonicalLocales(tag)[0], canonical); + + // Unicode extensions don't change the canonicalization result. + for (let ext of extensions) { + assertEq(Intl.getCanonicalLocales(tag + ext)[0], canonical + ext); + assertEq(Intl.getCanonicalLocales(canonical + ext)[0], canonical + ext); + } + + for (let intlCtor of intlConstructors) { + for (let opt of options) { + // The non-canonical tag is supported iff the canonical tag is supported. + let supported = intlCtor.supportedLocalesOf(tag, opt); + let supportedCanonical = intlCtor.supportedLocalesOf(canonical, opt); + assertEq(supported.length, supportedCanonical.length); + + let isSupported = supported.length > 0; + if (isSupported) { + assertEq(supported[0], canonical); + assertEq(supportedCanonical[0], canonical); + } + + // Unicode extensions don't change the result of supportedLocalesOf(). + for (let ext of extensions) { + let supportedExt = intlCtor.supportedLocalesOf(tag + ext, opt); + let supportedCanonicalExt = intlCtor.supportedLocalesOf(canonical + ext, opt); + assertEq(supportedExt.length, supportedCanonical.length); + assertEq(supportedCanonicalExt.length, supportedCanonical.length); + + if (isSupported) { + assertEq(supportedExt[0], canonical + ext); + assertEq(supportedCanonicalExt[0], canonical + ext); + } + } + } + } +} + +if (typeof reportCompare === "function") + reportCompare(0, 0); |