1Test::Stream::Table(3)User Contributed Perl DocumentationTest::Stream::Table(3)
2
3
4

NAME

6       Test::Stream::Table - Format a header and rows into a table
7

DEPRECATED

9       This distribution is deprecated in favor of Test2, Test2::Suite, and
10       Test2::Workflow.
11
12       See Test::Stream::Manual::ToTest2 for a conversion guide.
13

DESCRIPTION

15       This is used by some failing tests to provide diagnostics about what
16       has gone wrong. This module is able to generic format rows of data into
17       tables.
18

SYNOPSIS

20           use Test::Stream::Table qw/table/;
21
22           my @table = table(
23               max_width => 80,
24               collapse => 1, # Do not show empty columns
25               header => [ 'name', 'age', 'hair color' ],
26               rows => [
27                   [ 'Fred Flinstone',  2000000, 'black' ],
28                   [ 'Wilma Flinstone', 1999995, 'red' ],
29                   ...,
30               ],
31           );
32
33           # The @table array contains each line of the table, no newlines added.
34           say $_ for @table;
35
36       This prints a table like this:
37
38           +-----------------+---------+------------+
39           | name            | age     | hair color |
40           +-----------------+---------+------------+
41           | Fred Flinstone  | 2000000 | black      |
42           | Wilma Flinstone | 1999995 | red        |
43           | ...             | ...     | ...        |
44           +-----------------+---------+------------+
45

EXPORTS

47   @rows = table(...)
48       The function returns a list of lines, lines do not have the newline
49       "\n" character appended.
50
51       Options:
52
53       header => [ ... ]
54           If you want a header specify it here. This takes an arrayref with
55           each columns heading.
56
57       rows => [ [...], [...], ... ]
58           This should be an arrayref containing an arrayref per row.
59
60       collapse => $bool
61           Use this if you want ot hide empty columns, that is any column that
62           has no data in any row. Having a header for the column will not
63           effect collapse.
64
65       max_width => $num
66           Set the maximum width of the table, the table may not be this big,
67           but it will be no bigger. If none is specified it will attempt to
68           fidn the width of your terminal and use that, otherwise it falls
69           back to 80.
70
71       sanitize => $bool
72           This will sanitize all the data in the table such that newlines,
73           control characters, and all whitespace except for ASCII 20 ' ' are
74           replaced with escape sequences. This prevents newlines, tabs, and
75           similar whitespace from disrupting the table.
76
77       mark_tail => $bool
78           This will replace the last whitespace character of any trailing
79           whitespace with its escape sequence. This makes it easier to notice
80           trailing whitespace when comparing values.
81

NOTE ON UNICODE/WIDE CHARATERS

83       Some unicode characters, such as "婧" ("U+5A67") are wider than others.
84       These will render just fine if you "use utf8;" as necessary, and
85       Unicode::GCString is installed, however if the module is not installed
86       there will be anomolies in the table:
87
88           +-----+-----+---+
89           | a   | b   | c |
90           +-----+-----+---+
91           | 婧 | x   | y |
92           | x   | y   | z |
93           | x   | 婧 | z |
94           +-----+-----+---+
95

SOURCE

97       The source code repository for Test::Stream can be found at
98       http://github.com/Test-More/Test-Stream/.
99

MAINTAINERS

101       Chad Granum <exodist@cpan.org>
102

AUTHORS

104       Chad Granum <exodist@cpan.org>
105
107       Copyright 2015 Chad Granum <exodist7@gmail.com>.
108
109       This program is free software; you can redistribute it and/or modify it
110       under the same terms as Perl itself.
111
112       See http://dev.perl.org/licenses/
113
114
115
116perl v5.34.0                      2022-01-21            Test::Stream::Table(3)
Impressum