Text-Tabulate
view release on metacpan or search on metacpan
# -*- perl -*-
# Test the tabulate fuction.
use 5;
use warnings;
use strict;
use Test::More tests => 12;
# Tests
BEGIN { use_ok('Text::Tabulate'); }
$/ = ''; # paragraph mode.
# Load the data.
my $data = <DATA>;
chomp $data;
ok($data, 'data loaded');
my @data = split(/\n/, $data);
@data = ( $data );
# Test the routine.
while ($_ = <DATA>)
{
# Initialisation.
my $tab = "\t";
my $pad = " ";
my $gutter = ' ';
my $left = '';
my $right = '';
my $adjust = '';
my $top = '';
my $bottom = '';
# Load the test
my ($test, @test) = split(/\n/, $_);
eval $test;
# replace eol string
for (@test)
{
$_ .= "\n";
}
#print "$test\n", join("\n", @test), "\n\n";
#print "max=$max\n";
# run the test.
my @result;
my $obj = new Text::Tabulate();
eval {
$obj->configure(
tab=>$tab,
pad=>$pad,
gutter=>$gutter,
left=>$left,
right=>$right,
adjust => $adjust,
top=>$top,
bottom=>$bottom,
);
@result = $obj->format(@data);
};
if ($@) { warn $@; }
ok(@result, 'process table');
# Check.
is_deeply(\@result, \@test, $test);
#print join("\n", @result), "\n\n";
( run in 0.861 second using v1.01-cache-2.11-cpan-364913b4093 )