(listFormat)
| 17 | } |
| 18 | |
| 19 | function 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 | } |
| 49 | testFormatter(new Intl.ListFormat()); |
| 50 | testFormatter(new Intl.ListFormat(["en"])); |
| 51 | testFormatter(new Intl.ListFormat(["en"], {style: 'long'})); |
no test coverage detected