Debian Codegraph @

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

raw
1 if (typeof Intl === "object") {
2 const localeSep = [,,].toLocaleString();
3
4 // Missing arguments are passed as |undefined|.
5 const objNoArgs = {
6 toLocaleString() {
7 assertEq(arguments.length, 2);
8 assertEq(arguments[0], undefined);
9 assertEq(arguments[1], undefined);
10 return "pass";
11 }
12 };
13 // - Single element case.
14 assertEq([objNoArgs].toLocaleString(), "pass");
15 // - More than one element.
16 assertEq([objNoArgs, objNoArgs].toLocaleString(), "pass" + localeSep + "pass");
17
18 // Ensure "locales" and "options" arguments are passed to the array elements.
19 const locales = {}, options = {};
20 const objWithArgs = {
21 toLocaleString() {
22 assertEq(arguments.length, 2);
23 assertEq(arguments[0], locales);
24 assertEq(arguments[1], options);
25 return "pass";
26 }
27 };
28 // - Single element case.
29 assertEq([objWithArgs].toLocaleString(locales, options), "pass");
30 // - More than one element.
31 assertEq([objWithArgs, objWithArgs].toLocaleString(locales, options), "pass" + localeSep + "pass");
32 }
33
34 if (typeof reportCompare === "function")
35 reportCompare(true, true);