MCPcopy Index your code
hub / github.com/nodejs/node / testFormatter

Function testFormatter

deps/v8/test/intl/list-format/format.js:19–48  ·  view source on GitHub ↗
(listFormat)

Source from the content-addressed store, hash-verified

17}
18
19function testFormatter(listFormat) {
20 assertListFormat(listFormat, []);
21 assertListFormat(listFormat, undefined);
22 assertListFormat(listFormat, ['1']);
23 assertListFormat(listFormat, ['a']);
24 assertListFormat(listFormat, ['1', 'b']);
25 assertListFormat(listFormat, ['1', 'b', '3']);
26 assertListFormat(listFormat, ['a', 'b']);
27 assertListFormat(listFormat, ['a', 'b', 'c']);
28 assertListFormat(listFormat, ['a', 'b', 'c', 'd']);
29 assertListFormat(listFormat, ['作者', '譚永鋒', '1', (new Date()).toString()]);
30 assertListFormat(listFormat, ['作者', '譚永鋒', '1', 'b', '3']);
31
32 assertThrows(() => listFormat.format(null), TypeError);
33 assertThrows(() => listFormat.format([new Date()]), TypeError);
34 assertThrows(() => listFormat.format([1]), TypeError);
35 assertThrows(() => listFormat.format([1, 'b']), TypeError);
36 assertThrows(() => listFormat.format([1, 'b', 3]), TypeError);
37 assertThrows(() => listFormat.format([[3, 4]]), TypeError);
38 assertThrows(() => listFormat.format([undefined, 'world']), TypeError);
39 assertThrows(() => listFormat.format(['hello', undefined]), TypeError);
40 assertThrows(() => listFormat.format([undefined]), TypeError);
41 assertThrows(() => listFormat.format([null, 'world']), TypeError);
42 assertThrows(() => listFormat.format(['hello', null]), TypeError);
43 assertThrows(() => listFormat.format([null]), TypeError);
44
45 // Test that Cons strings are handled correctly.
46 let arr = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"];
47 assertListFormat(listFormat, [arr + "n"]);
48}
49testFormatter(new Intl.ListFormat());
50testFormatter(new Intl.ListFormat(["en"]));
51testFormatter(new Intl.ListFormat(["en"], {style: 'long'}));

Callers 1

format.jsFile · 0.70

Calls 4

assertListFormatFunction · 0.70
formatMethod · 0.65
assertThrowsFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected