diff -cr Template-Plugin-Group-1.03.orig/lib/Template/Plugin/Group.pm Template-Plugin-Group-1.03/lib/Template/Plugin/Group.pm
*** Template-Plugin-Group-1.03.orig/lib/Template/Plugin/Group.pm 2008-08-23 21:03:29.000000000 +0900
--- Template-Plugin-Group-1.03/lib/Template/Plugin/Group.pm 2009-11-18 10:42:53.000000000 +0900
***************
*** 90,97 ****
# Support the padding option
if ( grep { defined $_ and lc $_ eq 'pad' } @_ ) {
! my $items = scalar(@array) % $cols;
! push @array, (undef) x $items;
}
# Create the outside array and pack it
--- 90,99 ----
# Support the padding option
if ( grep { defined $_ and lc $_ eq 'pad' } @_ ) {
! my $items = scalar(@array) % $cols;
! if ($items) {
! push @array, (undef) x ($cols - $items);
! }
}
# Create the outside array and pack it
diff -cr Template-Plugin-Group-1.03.orig/t/02_main.t Template-Plugin-Group-1.03/t/02_main.t
*** Template-Plugin-Group-1.03.orig/t/02_main.t 2008-08-23 21:03:29.000000000 +0900
--- Template-Plugin-Group-1.03/t/02_main.t 2009-11-18 10:47:12.000000000 +0900
***************
*** 8,14 ****
$^W = 1;
}
! use Test::More tests => 4;
use Template::Plugin::Group ();
# Prepare
--- 8,14 ----
$^W = 1;
}
! use Test::More tests => 6;
use Template::Plugin::Group ();
# Prepare
***************
*** 25,27 ****
--- 25,39 ----
# Do a padded grouping
is_deeply( $TPG->new( $testdata, 2, 'pad' ), $padded, 'Padded grouping groups correctly' );
is_deeply( $testdata, $backup, 'Padded grouping doesnt break original ARRAY ref' );
+
+ {
+ my $testdata = [ 'foo', 'bar', 'baz' ];
+ my $grouped = [ [ 'foo', 'bar', 'baz' ] ];
+ is_deeply( $TPG->new( $testdata, 3, 'pad' ), $grouped );
+ }
+
+ {
+ my $testdata = [ 'foo', 'bar', 'baz', 'foo', 'bar' ];
+ my $grouped = [ [ 'foo', 'bar', 'baz', 'foo' ], [ 'bar', undef, undef, undef ] ];
+ is_deeply( $TPG->new( $testdata, 4, 'pad' ), $grouped );
+ }