1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
use strict;
use warnings;
BEGIN {
if (eval { require Test2::Tools::Tiny }) {
print "# Using Test2::Tools::Tiny\n";
Test2::Tools::Tiny->import();
}
elsif (eval { require Test::More; Test::More->can('done_testing') ? 1 : 0 }) {
print "# Using Test::More " . Test::More->VERSION . "\n";
Test::More->import();
}
else {
print "1..0 # SKIP Neither Test2::Tools::Tiny nor a sufficient Test::More is installed\n";
exit(0);
}
}
use Term::Table;
use Term::Table::Cell;
# This example was produced from the end result of another process, the end
# result is reproduced here in shortcuts:
chomp(my $inner = <<EOT);
+------+-----+-----+-------+--------+
| PATH | GOT | OP | CHECK | LINES |
+------+-----+-----+-------+--------+
| [0] | x | ANY |> ... <| 26, 30 |
| | | | a | 27 |
| | | | b | 28 |
| | | | c | 29 |
+------+-----+-----+-------+--------+
EOT
my $rows = [[
'',
'',
bless({'value' => $inner}, 'Term::Table::Cell'),
bless({'value' => 'eq'}, 'Term::Table::Cell'),
bless({'value' => ""}, 'Term::Table::Cell'),
'',
bless({'value' => '67'}, 'Term::Table::Cell'),
''
],
];
my $table = Term::Table->new(
collapse => 1,
sanitize => 1,
mark_tail => 1,
show_header => 1,
term_size => 80,
header => [qw/PATH LINES GOT OP CHECK * LINES NOTES/],
no_collapse => [qw/GOT CHECK/],
rows => $rows,
);
is_deeply(
[ $table->render ],
[
'+-----------------------------------------+----+-------+-------+',
'| GOT | OP | CHECK | LINES |',
'+-----------------------------------------+----+-------+-------+',
'| +------+-----+-----+-------+--------+\n | eq | | 67 |',
'| | PATH | GOT | OP | CHECK | LINES |\n | | | |',
'| +------+-----+-----+-------+--------+\n | | | |',
'| | [0] | x | ANY |> ... <| 26, 30 |\n | | | |',
'| | | | | a | 27 |\n | | | |',
'| | | | | b | 28 |\n | | | |',
'| | | | | c | 29 |\n | | | |',
'| +------+-----+-----+-------+--------+ | | | |',
'+-----------------------------------------+----+-------+-------+',
],
"Table looks right"
);
print map { "$_\n" } $table->render;
done_testing;
|