Debian Codegraph @

js/src/tests/non262/Intl/Array/toLocaleString-number.js

raw
1 if (typeof Intl === "object") {
2 const localeSep = [,,].toLocaleString();
3
4 assertEq([NaN].toLocaleString("ar"), "ليس رقمًا");
5 assertEq([NaN].toLocaleString(["zh-hant", "ar"]), "非數值");
6 assertEq([Infinity].toLocaleString("dz"), "གྲངས་མེད");
7 assertEq([-Infinity].toLocaleString(["fr", "en"]), "-∞");
8
9 const sampleValues = [
10 -0, +0, -1, +1, -2, +2, -0.5, +0.5,
11 ];
12 const sampleLocales = [
13 void 0,
14 "en",
15 "th-th-u-nu-thai",
16 ["tlh", "de"],
17 ];
18 const sampleOptions = [
19 void 0,
20 {},
21 {style: "percent"},
22 {style: "currency", currency: "USD", minimumIntegerDigits: 4},
23 ];
24 for (let locale of sampleLocales) {
25 for (let options of sampleOptions) {
26 let nf = new Intl.NumberFormat(locale, options);
27 let expected = sampleValues.map(nf.format).join(localeSep);
28 assertEq(sampleValues.toLocaleString(locale, options), expected);
29 }
30 }
31 }
32
33 if (typeof reportCompare === "function")
34 reportCompare(true, true);