From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- ...de-bcp47-locale-ids-variants-legacy-mappings.js | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 js/src/tests/non262/Intl/unicode-bcp47-locale-ids-variants-legacy-mappings.js (limited to 'js/src/tests/non262/Intl/unicode-bcp47-locale-ids-variants-legacy-mappings.js') diff --git a/js/src/tests/non262/Intl/unicode-bcp47-locale-ids-variants-legacy-mappings.js b/js/src/tests/non262/Intl/unicode-bcp47-locale-ids-variants-legacy-mappings.js new file mode 100644 index 0000000000..41b2a9a5cb --- /dev/null +++ b/js/src/tests/non262/Intl/unicode-bcp47-locale-ids-variants-legacy-mappings.js @@ -0,0 +1,47 @@ +// |reftest| skip-if(!this.hasOwnProperty("Intl")) + +// ECMA-402 includes mapping of legacy variants, as long as they're also present +// in in CLDR's supplementalMetadata.xml +// + +assertEq(Intl.getCanonicalLocales("sv-AALAND")[0], "sv-AX"); +assertEq(Intl.getCanonicalLocales("no-BOKMAL")[0], "nb"); +assertEq(Intl.getCanonicalLocales("no-NYNORSK")[0], "nn"); +assertEq(Intl.getCanonicalLocales("en-POSIX")[0], "en-posix"); +assertEq(Intl.getCanonicalLocales("el-POLYTONI")[0], "el-polyton"); +assertEq(Intl.getCanonicalLocales("aa-SAAHO")[0], "ssy"); + +// Additional cases from CLDR, version 38. + +assertEq(Intl.getCanonicalLocales("aar-saaho")[0], "ssy"); +assertEq(Intl.getCanonicalLocales("arm-arevmda")[0], "hyw"); +assertEq(Intl.getCanonicalLocales("hy-arevmda")[0], "hyw"); +assertEq(Intl.getCanonicalLocales("hye-arevmda")[0], "hyw"); + +for (let language of ["chi", "cmn", "zh", "zho"]) { + assertEq(Intl.getCanonicalLocales(language)[0], "zh"); + + let mapping = { + "guoyu-hakka": "hak", + "guoyu-xiang": "hsn", + "guoyu": "zh", + "hakka": "hak", + "xiang": "hsn", + }; + for (let [variant, canonical] of Object.entries(mapping)) { + assertEq(Intl.getCanonicalLocales(`${language}-${variant}`)[0], canonical); + } +} + +// Most legacy variant subtags are simply removed in contexts they don't apply. +for (let variant of ["arevela", "arevmda", "bokmal", "hakka", "lojban", "nynorsk", "saaho", "xiang"]) { + assertEq(Intl.getCanonicalLocales(`en-${variant}`)[0], "en"); +} + +// Except these three, whose replacement is always applied. +assertEq(Intl.getCanonicalLocales("en-aaland")[0], "en-AX"); +assertEq(Intl.getCanonicalLocales("en-heploc")[0], "en-alalc97"); +assertEq(Intl.getCanonicalLocales("en-polytoni")[0], "en-polyton"); + +if (typeof reportCompare === "function") + reportCompare(true, true); -- cgit v1.2.3