blob: 45d0e25a27cfea3620b7faa004ecd36ac84bf85d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!./perl
#
# grep() and map() tests
#
print "1..3\n";
$test = 1;
sub ok {
my ($got,$expect) = @_;
print "# expected [$expect], got [$got]\nnot " if $got ne $expect;
print "ok $test\n";
}
{
my @lol = ([qw(a b c)], [], [qw(1 2 3)]);
my @mapped = map {scalar @$_} @lol;
ok "@mapped", "3 0 3";
$test++;
my @grepped = grep {scalar @$_} @lol;
ok "@grepped", "$lol[0] $lol[2]";
$test++;
@grepped = grep { $_ } @mapped;
ok "@grepped", "3 3";
$test++;
}
|