Debian Codegraph @

t/01text07.t

raw
1 #! perl
2
3 use strict;
4 use warnings;
5 use Test::More qw(no_plan);
6
7 use Data::Report;
8
9 my $rep = Data::Report::->create(type => "text", stylist => \&my_stylist);
10
11 $rep->set_layout
12 ([ { name => "one", title => "One", width => 10, },
13 { name => "two", title => "Two", width => 11, },
14 { name => "thr", title => "Three", width => 12, },
15 { name => "fou", title => "Four", width => 13, },
16 { name => "fiv", title => "Five", width => 14, },
17 ]);
18
19 my $ref; { undef $/; $ref = <DATA>; }
20 $ref =~ s/[\r\n]/\n/g;
21 my $out = "";
22
23 my $dd = "The quick brown fox jumps over the lazy dog.";
24 $dd = "$dd $dd $dd";
25
26 $rep->set_output(\$out);
27 $rep->start;
28 $rep->add({ one => $dd, two => $dd, thr => $dd, fou => $dd, fiv => $dd });
29 $rep->finish;
30
31 is($out, $ref);
32
33 sub my_stylist {
34 my ($rep, $row, $col) = @_;
35
36 return unless defined $col;
37
38 return { ignore => 1, indent => 2 } if $col eq "two";
39 return { indent => 1, wrap_indent => 0 } if $col eq "thr";
40 return { wrap_indent => 2 } if $col eq "fou";
41 return { indent => 1, wrap_indent => 2 } if $col eq "fiv";
42
43 return;
44 }
45
46 __DATA__
47 One Three Four Five
48 -------------------------------------------------------
49 The quick The quick The quick The quick
50 brown fox brown fox brown fox brown fox
51 jumps over jumps over jumps over jumps over
52 the lazy the lazy the lazy the lazy
53 dog. The dog. The dog. The dog. The
54 quick quick brown quick brown quick brown
55 brown fox fox jumps fox jumps fox jumps
56 jumps over over the over the over the
57 the lazy lazy dog. lazy dog. lazy dog.
58 dog. The The quick The quick The quick
59 quick brown fox brown fox brown fox
60 brown fox jumps over jumps over jumps over
61 jumps over the lazy the lazy the lazy
62 the lazy dog. dog. dog.
63 dog.