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/alias-and-parent-locales.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/Intl/DisplayNames/alias-and-parent-locales.js')
-rw-r--r-- | js/src/tests/non262/Intl/DisplayNames/alias-and-parent-locales.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/js/src/tests/non262/Intl/DisplayNames/alias-and-parent-locales.js b/js/src/tests/non262/Intl/DisplayNames/alias-and-parent-locales.js new file mode 100644 index 0000000000..d60a1593d4 --- /dev/null +++ b/js/src/tests/non262/Intl/DisplayNames/alias-and-parent-locales.js @@ -0,0 +1,33 @@ +// |reftest| skip-if(!this.hasOwnProperty('Intl')) + +// Ensure alias and parent locales are correctly picked up when calling into ICU. + +// "zh-HK" is an alias to "zh-Hant-HK", so display names should default to +// traditional instead of simplified characters. +{ + const zh_Hant = new Intl.DisplayNames("zh-Hant", {type: "region"}); + const zh_Hans = new Intl.DisplayNames("zh-Hans", {type: "region"}); + const zh_HK = new Intl.DisplayNames("zh-HK", {type: "region"}); + + // We assume traditional and simplified have different outputs. + assertEq(zh_Hant.of("US") === zh_Hans.of("US"), false); + + // "zh-HK" should use traditional characters. + assertEq(zh_HK.of("US"), zh_Hant.of("US")); +} + +// The parent locale of "en-AU" is "en-001" and not "en" (because "en" actually means "en-US"). +{ + const en = new Intl.DisplayNames("en", {type: "language"}); + const en_001 = new Intl.DisplayNames("en-001", {type: "language"}); + const en_AU = new Intl.DisplayNames("en-AU", {type: "language"}); + + // We assume "en" and "en-001" have different outputs. + assertEq(en.of("nds-NL") === en_001.of("nds-NL"), false); + + // "en-AU" should have the same output as "en-001". + assertEq(en_AU.of("nds-NL"), en_001.of("nds-NL")); +} + +if (typeof reportCompare === "function") + reportCompare(true, true); |