Skip Menu |

This queue is for tickets about the Template-Plugin-Group CPAN distribution.

Report information
The Basics
Id: 51558
Status: new
Priority: 0/
Queue: Template-Plugin-Group

People
Owner: Nobody in particular
Requestors: bokutin [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.03
Fixed in: (no value)



Subject: 'pad' bug
Hi. I used this plugin usefully. I found bit bug. *** lib/Template/Plugin/Group.pm.orig 2008-08-23 21:03:29.000000000 +0900 --- lib/Template/Plugin/Group.pm 2009-11-16 05:05:35.000000000 +0900 *************** *** 91,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 --- 91,97 ---- # Support the padding option if ( grep { defined $_ and lc $_ eq 'pad' } @_ ) { my $items = scalar(@array) % $cols; ! push @array, (undef) x ($cols - $items); } # Create the outside array and pack it Thanks,
On 日曜日 11月 15 15:11:43 2009, bokutin wrote: Show quoted text
> Hi. > > I used this plugin usefully. > > I found bit bug. > > *** lib/Template/Plugin/Group.pm.orig 2008-08-23 21:03:29.000000000 +0900 > --- lib/Template/Plugin/Group.pm 2009-11-16 05:05:35.000000000 +0900 > *************** > *** 91,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 > --- 91,97 ---- > # Support the padding option > if ( grep { defined $_ and lc $_ eq 'pad' } @_ ) { > my $items = scalar(@array) % $cols; > ! push @array, (undef) x ($cols - $items); > } > > # Create the outside array and pack it > > Thanks,
I created new patch.
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 ); + }