summaryrefslogtreecommitdiff
path: root/t/op/grep.t
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-01-26 02:42:38 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-01-26 02:42:38 +0000
commit2c38e13daec4f9e65bad30c43fc6df91a507e2ca (patch)
tree815e625189864f2ebc95c492cb0c4f04bbf25670 /t/op/grep.t
parentaff0d67d6040325b97c3a65dfacc0da27cbd77e4 (diff)
downloadperl-2c38e13daec4f9e65bad30c43fc6df91a507e2ca.tar.gz
change#3744 should have made grep more like map instead of the
other way around p4raw-link: @3744 on //depot/perl: 4e4e412b11cee5b4d44ee0d29943215db93eb350 p4raw-id: //depot/perl@4897
Diffstat (limited to 't/op/grep.t')
-rwxr-xr-xt/op/grep.t70
1 files changed, 69 insertions, 1 deletions
diff --git a/t/op/grep.t b/t/op/grep.t
index 45d0e25a27..3a7f8ad984 100755
--- a/t/op/grep.t
+++ b/t/op/grep.t
@@ -4,7 +4,7 @@
# grep() and map() tests
#
-print "1..3\n";
+print "1..27\n";
$test = 1;
@@ -29,3 +29,71 @@ sub ok {
$test++;
}
+{
+ print map({$_} ("ok $test\n"));
+ $test++;
+ print map
+ ({$_} ("ok $test\n"));
+ $test++;
+ print((map({a => $_}, ("ok $test\n")))[0]->{a});
+ $test++;
+ print((map
+ ({a=>$_},
+ ("ok $test\n")))[0]->{a});
+ $test++;
+ print map { $_ } ("ok $test\n");
+ $test++;
+ print map
+ { $_ } ("ok $test\n");
+ $test++;
+ print((map {a => $_}, ("ok $test\n"))[0]->{a});
+ $test++;
+ print((map
+ {a=>$_},
+ ("ok $test\n"))[0]->{a});
+ $test++;
+ my $x = "ok \xFF\xFF\n";
+ print map($_&$x,("ok $test\n"));
+ $test++;
+ print map
+ ($_ & $x, ("ok $test\n"));
+ $test++;
+ print map { $_ & $x } ("ok $test\n");
+ $test++;
+ print map
+ { $_&$x } ("ok $test\n");
+ $test++;
+
+ print grep({$_} ("ok $test\n"));
+ $test++;
+ print grep
+ ({$_} ("ok $test\n"));
+ $test++;
+ print grep({a => $_}->{a}, ("ok $test\n"));
+ $test++;
+ print grep
+ ({a => $_}->{a},
+ ("ok $test\n"));
+ $test++;
+ print grep { $_ } ("ok $test\n");
+ $test++;
+ print grep
+ { $_ } ("ok $test\n");
+ $test++;
+ print grep {a => $_}->{a}, ("ok $test\n");
+ $test++;
+ print grep
+ {a => $_}->{a},
+ ("ok $test\n");
+ $test++;
+ print grep($_&"X",("ok $test\n"));
+ $test++;
+ print grep
+ ($_&"X", ("ok $test\n"));
+ $test++;
+ print grep { $_ & "X" } ("ok $test\n");
+ $test++;
+ print grep
+ { $_ & "X" } ("ok $test\n");
+ $test++;
+}