X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fgrep.t;h=3e5d7168a0dc17b78398ccea579469c62277a1b8;hb=e081bb54e0eecfb962e7f0cfd84fcbdb2683d54d;hp=5f4e7a61732272a976b166ee70bbfd102d53bc41;hpb=b3c0f1bde204be7b0c1795e8d30824df46a47ce0;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/grep.t b/t/op/grep.t index 5f4e7a6..3e5d716 100755 --- a/t/op/grep.t +++ b/t/op/grep.t @@ -4,7 +4,7 @@ # grep() and map() tests # -print "1..33\n"; +print "1..38\n"; $test = 1; @@ -140,6 +140,30 @@ sub ok { map {"${_}x"} @_; }; ok join("-",add_an_x(1,2,3,4)), "1x-2x-3x-4x"; + $test++; } +{ + my $gimme; + + sub gimme { + my $want = wantarray(); + if (defined $want) { + $gimme = $want ? 'list' : 'scalar'; + } else { + $gimme = 'void'; + } + } + + my @list = 0..9; + undef $gimme; gimme for @list; ok($gimme, 'void'); $test++; + undef $gimme; grep { gimme } @list; ok($gimme, 'scalar'); $test++; + undef $gimme; map { gimme } @list; ok($gimme, 'list'); $test++; +} + +{ + # This shouldn't loop indefinitively. + my @empty = map { while (1) {} } (); + ok("@empty", ''); +}