Debian Codegraph @

js/src/tests/non262/Intl/DisplayNames/alias-and-parent-locales.js

raw
1 // |reftest| skip-if(!this.hasOwnProperty('Intl'))
2
3 // Ensure alias and parent locales are correctly picked up when calling into ICU.
4
5 // "zh-HK" is an alias to "zh-Hant-HK", so display names should default to
6 // traditional instead of simplified characters.
7 {
8 const zh_Hant = new Intl.DisplayNames("zh-Hant", {type: "region"});
9 const zh_Hans = new Intl.DisplayNames("zh-Hans", {type: "region"});
10 const zh_HK = new Intl.DisplayNames("zh-HK", {type: "region"});
11
12 // We assume traditional and simplified have different outputs.
13 assertEq(zh_Hant.of("US") === zh_Hans.of("US"), false);
14
15 // "zh-HK" should use traditional characters.
16 assertEq(zh_HK.of("US"), zh_Hant.of("US"));
17 }
18
19 // The parent locale of "en-AU" is "en-001" and not "en" (because "en" actually means "en-US").
20 {
21 const en = new Intl.DisplayNames("en", {type: "language"});
22 const en_001 = new Intl.DisplayNames("en-001", {type: "language"});
23 const en_AU = new Intl.DisplayNames("en-AU", {type: "language"});
24
25 // We assume "en" and "en-001" have different outputs.
26 assertEq(en.of("nds-NL") === en_001.of("nds-NL"), false);
27
28 // "en-AU" should have the same output as "en-001".
29 assertEq(en_AU.of("nds-NL"), en_001.of("nds-NL"));
30 }
31
32 if (typeof reportCompare === "function")
33 reportCompare(true, true);