]> git.vpit.fr Git - perl/modules/Sub-Prototype-Util.git/commitdiff
_ shouldn't push elements in flatten, but skip them
authorVincent Pit <vince@profvince.com>
Mon, 3 Nov 2008 08:53:32 +0000 (09:53 +0100)
committerVincent Pit <vince@profvince.com>
Mon, 3 Nov 2008 08:53:32 +0000 (09:53 +0100)
lib/Sub/Prototype/Util.pm
t/10-flatten.t

index c5c6ffd94294b2dbb04041e136a765604f107736..a92647f6a4d224985ff72ac11dea3fd75ed980ca 100644 (file)
@@ -87,8 +87,8 @@ sub flatten {
   } elsif ($p =~ /[\@\%]/) {
    push @args, @_;
    last;
-  } elsif ($p eq '_' && @_ == 0) {
-   push @args, $_;
+  } elsif ($p eq '_') {
+   shift; # without prototype, this argument wouldn't have been passed
   } else {
    push @args, shift;
   }
index 8c23c3c105e390eaa0bf45b91a47ba43186735a0..414cfcf26305652eee0a07960b31dde6a6fd618d 100644 (file)
@@ -41,10 +41,8 @@ my @tests = (
  [ '\[$@%]',   'class got scalarref',    [ \1 ], [ 1 ] ],
  [ '\[$@%]',   'class got arrayref',  [ [ 1 ] ], [ 1 ] ],
  [ '\[$@%]',   'class got hashref', [ { 1,2 } ], [ 1, 2 ] ],
- [ '_',        '_ with argument',      [ 1, 2 ], [ 1 ] ]
+ [ '_',        '_ with argument',      [ 1, 2 ], [ ] ],
+ [ '_',        '_ with no argument',        [ ], [ ] ]
 );
-my $l = [ '_', '_ with no argument', [ ] ];
-$l->[3] = [ $l ];
-push @tests, $l;
 
 is_deeply( [ flatten($_->[0], @{$_->[2]}) ], $_->[3], $_->[1]) for @tests;