This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix bogus OPf_REF context for the BLOCK in C<grep BLOCK @foo>
[perl5.git] / t / op / grep.t
CommitLineData
fd3835b3
GS
1#!./perl
2
3#
4# grep() and map() tests
5#
6
7print "1..3\n";
8
9$test = 1;
10
11sub ok {
12 my ($got,$expect) = @_;
13 print "# expected [$expect], got [$got]\nnot " if $got ne $expect;
14 print "ok $test\n";
15}
16
17{
18 my @lol = ([qw(a b c)], [], [qw(1 2 3)]);
19 my @mapped = map {scalar @$_} @lol;
20 ok "@mapped", "3 0 3";
21 $test++;
22
23 my @grepped = grep {scalar @$_} @lol;
24 ok "@grepped", "$lol[0] $lol[2]";
25 $test++;
26
27 @grepped = grep { $_ } @mapped;
28 ok "@grepped", "3 3";
29 $test++;
30}
31