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
|
#! perl
use strict;
use warnings;
use Test::More qw(no_plan);
use Data::Report;
my $rep = Data::Report::->create(type => "text");
$rep->set_layout
([ { name => "acct", title => "Acct", width => 6 },
{ name => "desc", title => "Report", width => 40, align => "|" },
{ name => "deb", title => "Debet", width => 10, align => "<" },
{ name => "crd", title => "Credit", width => 10, align => ">" },
]);
my $out = "";
$rep->set_output(\$out);
$rep->set_fields([qw(desc crd deb acct)]);
$rep->set_width({ deb => 9, crd => '-1' });
$rep->start;
$rep->add({ acct => "one", desc => "two", deb => "three", crd => "four" });
$rep->finish;
$rep->close;
my $ref; { undef $/; $ref = <DATA>; }
$ref =~ s/[\r\n]/\n/g;
is($out, $ref);
__DATA__
Report Credit Debet Acct
----------------------------------------------------------------------
two four three one
|