summaryrefslogtreecommitdiff
path: root/t/op/grep.t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-09-14 17:46:52 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-09-14 17:46:52 +0000
commit20c514ece8742b452abf20fe2b2afe915c29bc47 (patch)
tree3481fe9df259489effc0f7394b17921501d74398 /t/op/grep.t
parent939b405b43945897061181f7ed38df50aec8b511 (diff)
downloadperl-20c514ece8742b452abf20fe2b2afe915c29bc47.tar.gz
Check the context of for/grep/map.
p4raw-id: //depot/perl@21230
Diffstat (limited to 't/op/grep.t')
-rwxr-xr-xt/op/grep.t21
1 files changed, 20 insertions, 1 deletions
diff --git a/t/op/grep.t b/t/op/grep.t
index 5a7c7c65a9..4696224c44 100755
--- a/t/op/grep.t
+++ b/t/op/grep.t
@@ -4,7 +4,7 @@
# grep() and map() tests
#
-print "1..34\n";
+print "1..37\n";
$test = 1;
@@ -140,6 +140,25 @@ 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++;
+}