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
|
#!/usr/bin/perl
# vim: set ft=perl:
use strict;
use Text::TabularDisplay;
use Test;
BEGIN {
plan tests => 4;
}
my @data = (
[ "Joe Shmoe", "red", "9 1/2" ],
[ qw(foo bar baz) ],
[ "Bob Smith", "chartreuse", "11" ],
[ qw(foo bar baz) ],
[ "Jumpin' Jack Flash", "yellow", "12" ],
[ qw(foo bar baz) ],
[ "Joe Shmoe", "red", "9 1/2" ],
[ qw(foo bar baz) ],
[ "Bob Smith", "chartreuse", "11" ],
[ qw(foo bar baz) ],
[ "Jumpin' Jack Flash", "yellow", "12" ],
[ qw(foo bar baz) ],
);
ok(my $t = Text::TabularDisplay->new("name", "favorite color", "shoe size"));
ok($t->populate([ @data ]));
ok($t->items, scalar @data);
ok($t->render, "+--------------------+----------------+-----------+
| name | favorite color | shoe size |
+--------------------+----------------+-----------+
| Joe Shmoe | red | 9 1/2 |
| foo | bar | baz |
| Bob Smith | chartreuse | 11 |
| foo | bar | baz |
| Jumpin' Jack Flash | yellow | 12 |
| foo | bar | baz |
| Joe Shmoe | red | 9 1/2 |
| foo | bar | baz |
| Bob Smith | chartreuse | 11 |
| foo | bar | baz |
| Jumpin' Jack Flash | yellow | 12 |
| foo | bar | baz |
+--------------------+----------------+-----------+");
|