Login
RT #79289: False Postive in Perl::Critic::Utils::is_in_void_context()
[gknop/Perl-Critic.git] / t / BuiltinFunctions / ProhibitVoidGrep.run
CommitLineData
6977a06e
ES
1## name Basic passing
2## failures 0
3## cut
4
6977a06e
ES
5print grep("$foo", @list);
6print ( grep "$foo", @list );
7@list = ( grep "$foo", @list );
8$aref = [ grep "$foo", @list ];
9$href = { grep "$foo", @list };
10
11if( grep { foo($_) } @list ) {}
12for( grep { foo($_) } @list ) {}
13
14#-----------------------------------------------------------------------------
15
16## name Basic failure
17## failures 7
18## cut
19
20grep "$foo", @list;
21grep("$foo", @list);
22grep { foo($_) } @list;
23grep({ foo($_) } @list);
24
25if( $condition ){ grep { foo($_) } @list }
26while( $condition ){ grep { foo($_) } @list }
27for( @list ){ grep { foo($_) } @list }
28
29#-----------------------------------------------------------------------------
30
b34e4aff
CD
31## name Comma operator
32## failures 1
33## TODO not handled properly
34## cut
35
36$baz, grep "$foo", @list;
37
38#-----------------------------------------------------------------------------
39
6977a06e
ES
40## name Chained void grep
41## failures 1
42## cut
43
b34e4aff
CD
44grep { spam($_) }
45 grep { foo($_) }
46 grep { bar($_) }
47 grep { baz($_) } @list;
6977a06e
ES
48
49#-----------------------------------------------------------------------------
50
b946a486
TW
51## name Subscript grep (RT #79289)
52## failures 0
53## cut
54
55my %hash;
56
57delete @hash{ grep { m/ foo /smx } keys %hash };
58delete @hash{ grep m/ foo /smx, keys %hash };
59# The following is the form that was actually failing.
60delete @hash{ grep ( m/ foo /smx, keys %hash ) };
61
62#-----------------------------------------------------------------------------
63
6977a06e
ES
64##############################################################################
65# $URL$
66# $Date$
67# $Author$
68# $Revision$
69##############################################################################
70
71# Local Variables:
72# mode: cperl
73# cperl-indent-level: 4
74# fill-column: 78
75# indent-tabs-mode: nil
76# c-indentation-style: bsd
77# End:
96fed375 78# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :