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/DisplayNames/language-dialect.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/DisplayNames/language-dialect.js | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/js/src/tests/non262/Intl/DisplayNames/language-dialect.js b/js/src/tests/non262/Intl/DisplayNames/language-dialect.js new file mode 100644 index 0000000000..c2999bd673 --- /dev/null +++ b/js/src/tests/non262/Intl/DisplayNames/language-dialect.js @@ -0,0 +1,104 @@ +// |reftest| skip-if(!this.hasOwnProperty('Intl')) + +const tests = { + "en": { + long: { + "de": "German", + "de-AT": "Austrian German", + "de-1996": "German (German orthography of 1996)", + "en": "English", + "en-Hant-GB": "British English (Traditional)", + "en-Hans-US": "American English (Simplified)", + "fr": "French", + "nl-BE": "Flemish", + "cr-Cans": "Cree (Unified Canadian Aboriginal Syllabics)", + }, + short: { + "en-Hant-GB": "UK English (Traditional)", + "en-Hans-US": "US English (Simplified)", + "cr-Cans": "Cree (UCAS)", + }, + narrow: {}, + }, + "de": { + long: { + "de": "Deutsch", + "de-AT": "Österreichisches Deutsch", + "de-1996": "Deutsch (Neue deutsche Rechtschreibung)", + "en": "Englisch", + "en-Hant-GB": "Englisch (Traditionell, Vereinigtes Königreich)", + "en-Hans-US": "Englisch (Vereinfacht, Vereinigte Staaten)", + "fr": "Französisch", + "nl-BE": "Flämisch", + }, + short: { + "en-Hant-GB": "Englisch (GB) (Traditionell)", + "en-Hans-US": "Englisch (USA) (Vereinfacht)", + }, + narrow: {}, + }, + "fr": { + long: { + "de": "allemand", + "de-AT": "allemand autrichien", + "de-1996": "allemand (orthographe allemande de 1996)", + "en": "anglais", + "en-Hant-GB": "anglais britannique (traditionnel)", + "en-Hans-US": "anglais américain (simplifié)", + "fr": "français", + "nl-BE": "flamand", + }, + short: { + "en-Hant-GB": "anglais britannique (traditionnel)", + "en-Hans-US": "anglais américain (simplifié)", + }, + narrow: {}, + }, + "zh": { + long: { + "zh": "中文", + "zh-Hant": "繁体中文", + "zh-Hant-CN": "繁体中文(中国)", + "zh-Hans-HK": "简体中文(中国香港特别行政区)", + }, + short: { + "zh-Hans-HK": "简体中文(香港)" + }, + narrow: {}, + }, + "ar": { + long: { + "ar": "العربية", + "ar-SA": "العربية (المملكة العربية السعودية)", + "zh-MO": "الصينية (منطقة ماكاو الإدارية الخاصة)", + }, + short: { + "zh-MO": "الصينية (مكاو)", + }, + narrow: {}, + }, +}; + +for (let [locale, localeTests] of Object.entries(tests)) { + for (let [style, styleTests] of Object.entries(localeTests)) { + let dn = new Intl.DisplayNames(locale, {type: "language", languageDisplay: "dialect", style}); + + let resolved = dn.resolvedOptions(); + assertEq(resolved.locale, locale); + assertEq(resolved.style, style); + assertEq(resolved.type, "language"); + assertEq(resolved.languageDisplay, "dialect"); + assertEq(resolved.fallback, "code"); + + let inheritedTests = {...localeTests.long, ...localeTests.short, ...localeTests.narrow}; + for (let [language, expected] of Object.entries({...inheritedTests, ...styleTests})) { + assertEq(dn.of(language), expected); + + // Also works with objects. + assertEq(dn.of(Object(language)), expected); + } + } +} + +if (typeof reportCompare === "function") + reportCompare(true, true); |