Codebase list liblatex-table-perl / f855a8f
undef lima1 12 years ago
4 changed file(s) with 59 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
00 Revision history for LaTeX-Table
11
2 1.1 Mon Oct 25 2011
2 1.1 Tue Feb 21 2012
33 - Removed version dependency
4 - Allowed undef values in data and header (thanks Dan, closes #75203)
45
56 1.0.6 Mon Oct 25 2010
67 - eor option (thanks Jens)
8787 has 'resizebox' => ( is => 'rw', isa => 'ArrayRef[Str]' );
8888 has 'columns_like_header' => ( is => 'rw', isa => 'ArrayRef[Int]' );
8989 has 'header' =>
90 ( is => 'rw', isa => 'ArrayRef[ArrayRef[Value]]', default => sub { [] } );
90 ( is => 'rw', isa => 'ArrayRef[ArrayRef]', default => sub { [] } );
9191 has 'data' =>
92 ( is => 'rw', isa => 'ArrayRef[ArrayRef[Value]]', default => sub { [] } );
92 ( is => 'rw', isa => 'ArrayRef[ArrayRef]', default => sub { [] } );
9393 has 'predef_themes' =>
9494 ( is => 'rw', isa => 'HashRef[HashRef]', default => sub { {} } );
9595 has 'custom_themes' =>
248248 my $i = 0;
249249 COL:
250250 for my $col ( @{$row} ) {
251 next COL if $col =~ $strategy->{MISSING_VALUE};
251 next COL if !defined $col || $col =~ $strategy->{MISSING_VALUE};
252252
253253 for my $coltype (@coltypes) {
254254 if ( $col =~ $strategy->{$coltype} ) {
534534
535535 sub _get_mc_def {
536536 my ( $self, $value ) = @_;
537 return { value => undef } if (!defined $value);
537538 return $value =~ m{ \A (.*)\:(\d+)([clr]) \s* \z }xms
538539 ? {
539540 value => $1,
0 use Test::More tests => 21;
0 use Test::More tests => 22;
11 use Test::NoWarnings;
22
33 use LaTeX::Table;
676676 'theme with colordef and resizebox'
677677 ) || diag $output;
678678
679
679 $test_header
680 = [ [ 'Name', 'Beers:2c' ], [ '', 'before 4pm', 'after 4pm' ] ];
681 $test_data = [
682 [ 'Lisa', '0', '0' ],
683 [ 'Marge', '0', '1' ],
684 [ 'Wiggum', '0', '5' ],
685 [ 'Otto', '1', '3' ],
686 [ 'Homer', '2', '6' ],
687 [ 'Barney', '8', undef ],
688 ];
689
690 $table = LaTeX::Table->new(
691 {
692 environment => 0,
693 header => $test_header,
694 data => $test_data,
695 callback => sub {
696 my ( $row, $col, $value, $is_header ) = @_;
697 if (!defined $value) {
698 $value = 'NA';
699 }
700 return $value;
701 }
702 }
703 );
704
705 $expected_output = <<'EOT'
706 \begin{tabular}{lrr}
707 \toprule
708 Name & \multicolumn{2}{c}{Beers} \\
709 & before 4pm & after 4pm \\
710 \midrule
711 Lisa & 0 & 0 \\
712 Marge & 0 & 1 \\
713 Wiggum & 0 & 5 \\
714 Otto & 1 & 3 \\
715 Homer & 2 & 6 \\
716 Barney & 8 & NA \\
717 \bottomrule
718 \end{tabular}
719 EOT
720 ;
721
722
723 $output = $table->generate_string();
724
725 is_deeply(
726 [ split( "\n", $output ) ],
727 [ split( "\n", $expected_output ) ],
728 'undefined columns'
729 ) || diag $output;
0 use Test::More tests => 35;
0 use Test::More tests => 33;
11 use Test::NoWarnings;
22
33 use LaTeX::Table;
109109 'header[0] is not an array reference'
110110 ) || diag $EVAL_ERROR;
111111
112 eval { $table->set_header( [ [ 'A', ['B'] ] ] ); };
113 like( $EVAL_ERROR, qr{Attribute \(header\)}, 'header[0][1] is not a scalar' )
114 || diag $EVAL_ERROR;
115
116112 # data tests
117113 eval {
118114 $table = LaTeX::Table->new(
130126 qr{Attribute \(data\)},
131127 'data[1] is not an array reference'
132128 ) || diag $EVAL_ERROR;
133
134 eval { $table->set_data( [ [ 'A', 'B' ], [ 'A', undef ] ] ); };
135 like( $EVAL_ERROR, qr{Attribute \(data\)}, 'undef value' )
136 || diag $EVAL_ERROR;
137129
138130 $table->set_data($data);
139131 eval { $table->set_coldef_strategy(1); };