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/Locale/likely-subtags.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/Locale/likely-subtags.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/js/src/tests/non262/Intl/Locale/likely-subtags.js b/js/src/tests/non262/Intl/Locale/likely-subtags.js new file mode 100644 index 0000000000..3b3e4bd905 --- /dev/null +++ b/js/src/tests/non262/Intl/Locale/likely-subtags.js @@ -0,0 +1,61 @@ +// |reftest| skip-if(!this.hasOwnProperty('Intl')) + +var testDataMaximal = { + // Keeps "und" primary language. + "und-AQ": "und-Latn-AQ", + + // Modifies primary language. + "und-Cyrl-RO": "bg-Cyrl-RO", +} + +var testDataMinimal = { + // Undefined primary language. + "und": "en", + "und-Thai": "th", + "und-419": "es-419", + "und-150": "ru", + "und-AT": "de-AT", + + // https://ssl.icu-project.org/trac/ticket/13786 + "aae-Latn-IT": "aae", + "aae-Thai-CO": "aae-Thai-CO", + + // https://ssl.icu-project.org/trac/ticket/10220 + // https://ssl.icu-project.org/trac/ticket/12345 + "und-CW": "pap", + "und-US": "en", + "zh-Hant": "zh-TW", + "zh-Hani": "zh-Hani", +}; + +// Add variants, extensions, and privateuse subtags and ensure they don't +// modify the result of the likely subtags algorithms. +var extras = [ + "fonipa", + "a-not-assigned", + "u-attr", + "u-co", + "u-co-phonebk", + "x-private", +]; + +for (var [tag, maximal] of Object.entries(testDataMaximal)) { + assertEq(new Intl.Locale(tag).maximize().toString(), maximal); + assertEq(new Intl.Locale(maximal).maximize().toString(), maximal); + + for (var extra of extras) { + assertEq(new Intl.Locale(tag + "-" + extra).maximize().toString(), maximal + "-" + extra); + } +} + +for (var [tag, minimal] of Object.entries(testDataMinimal)) { + assertEq(new Intl.Locale(tag).minimize().toString(), minimal); + assertEq(new Intl.Locale(minimal).minimize().toString(), minimal); + + for (var extra of extras) { + assertEq(new Intl.Locale(tag + "-" + extra).minimize().toString(), minimal + "-" + extra); + } +} + +if (typeof reportCompare === "function") + reportCompare(0, 0); |