File: 15.t

package info (click to toggle)
libtext-tabulardisplay-perl 1.22-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 164 kB
  • ctags: 15
  • sloc: perl: 712; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,675 bytes parent folder | download
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
#!/usr/bin/perl
# vim: set ft=perl:
# $Id: 15.t,v 1.1.1.1 2005/10/04 16:39:58 dlc Exp $

use strict;
use Text::TabularDisplay;
use Test;

BEGIN {
    plan tests => 1;
}

my @data = (
    [ "Joe\nShmoe", "r\ned", "9\n1/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'\nJack Flash", "yellow", "12" ],
    [ "foo", "bar", "ba\nz" ],
);

my $t = Text::TabularDisplay->new("name", "favorite color", "shoe\nsize");
$t->populate([ @data ]);
ok($t->render, "+--------------------+----------------+-------+
| name               | favorite color | shoe  |
|                    |                | size  |
+--------------------+----------------+-------+
| Joe                | r              | 9     |
| Shmoe              | ed             | 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'            | yellow         | 12    |
| Jack Flash         |                |       |
| foo                | bar            | ba    |
|                    |                | z     |
+--------------------+----------------+-------+");