Login
Unmark test as TODO.
[gknop/Perl-Critic.git] / t / ValuesAndExpressions / ProhibitCommaSeparatedStatements.run
CommitLineData
c948abe5
ES
1## name Basic passing
2## failures 0
3## cut
4
5@x = (@y, @z);
6my $expl = [133, 138];
7$lookup = { a => 1, b => 2 };
8
9#-----------------------------------------------------------------------------
10
11## name Basic failure
12## failures 1
13## cut
14
15@x = @y, @z;
16
17#-----------------------------------------------------------------------------
18
19## name List including assignments
20## failures 0
21## cut
22
23@w = ($x = 1, $y = 2, $z = 3);
24
25#-----------------------------------------------------------------------------
26
27## name List containing statement
28## failures 0
29## cut
30
31@w = ( {}, [] );
32
33#-----------------------------------------------------------------------------
34
35## name List containing statement in a constructor that is reported as a block
36## failures 0
37## cut
38
39my %foo = (
40 blah => {
41 blah => 'blah',
42 },
43);
44
45#-----------------------------------------------------------------------------
46
47## name Regular statement inside a block.
27ac78c7 48## failures 0
c948abe5
ES
49## cut
50
51foreach my $path ( @ARGV ) {
27ac78c7 52 utter 'Looking at ', $path, '.';
c948abe5
ES
53}
54
55#-----------------------------------------------------------------------------
56
57## name Sub call after comma
58## failures 1
59## cut
60
61@x = @y, foo @z;
62
63#-----------------------------------------------------------------------------
64
65## name Regular sub call before comma
66## failures 1
67## cut
68
27ac78c7
ES
69# The space between the sub name and the left parenthesis is significant
70# in that part of Conway's point is that things that look like lists may
71# not be.
72
73@x = foo (@y), @z;
c948abe5
ES
74
75#-----------------------------------------------------------------------------
76
77## name No-argument sub call via use of sigil
78## failures 1
79## cut
80
81@x = &foo, @y, bar @z;
82
83#-----------------------------------------------------------------------------
84
85## name Two sub calls
27ac78c7 86## failures 0
c948abe5
ES
87## cut
88
89@x = foo @y, bar @z;
90
91#-----------------------------------------------------------------------------
92
27ac78c7 93## name Built-in call that provides a list context without parentheses
c948abe5
ES
94## failures 0
95## cut
96
97@x = push @y, @z;
98
99#-----------------------------------------------------------------------------
100
101## name Built-in call that provides a list context, called like a function
102## failures 1
103## cut
104
105@x = push (@y), @z;
106
107#-----------------------------------------------------------------------------
108
109## name Built-in call that takes multiple arguments without parentheses
110## failures 0
111## cut
112
27ac78c7
ES
113@x = substr $y, 1, 2;
114
115#-----------------------------------------------------------------------------
116
117## name Built-in call that takes multiple arguments, called like a function
118## failures 1
119## cut
120
121@x = substr ($y, 1), 2;
122
123#-----------------------------------------------------------------------------
124
125## name Call to unary built-in without parentheses
126## failures 1
127## cut
128
129@x = tied @y, @z;
130
131#-----------------------------------------------------------------------------
132
133## name Unary built-in, called like a function
134## failures 1
135## cut
136
137@x = tied (@y), @z;
c948abe5
ES
138
139#-----------------------------------------------------------------------------
140
27ac78c7 141## name Call to no-argument built-in without parentheses
c948abe5
ES
142## failures 1
143## cut
144
27ac78c7 145@x = time, @z;
c948abe5
ES
146
147#-----------------------------------------------------------------------------
148
27ac78c7
ES
149## name No-argument built-in, called like a function
150## failures 1
151## cut
152
153@x = time (), @z;
154
155#-----------------------------------------------------------------------------
156
157## name Call to optional argument built-in without an argument without parentheses
158## failures 1
159## cut
160
161@x = sin, @z;
162
163#-----------------------------------------------------------------------------
164
165## name Optional argument built-in, called like a function without an argument
166## failures 1
167## cut
168
169@x = sin (), @z;
170
171#-----------------------------------------------------------------------------
172
173## name Call to optional argument built-in with an argument without parentheses
c948abe5
ES
174## failures 1
175## cut
176
177@x = sin @y, @z;
178
179#-----------------------------------------------------------------------------
180
27ac78c7
ES
181## name Optional argument built-in, called like a function with an argument
182## failures 1
183## cut
184
185@x = sin (@y), @z;
186
187#-----------------------------------------------------------------------------
188
c948abe5
ES
189## name For loop
190## failures 2
191## cut
192
193for ($x = 0, $y = 0; $x < 10; $x++, $y += 2) {
194 foo($x, $y);
195}
196
197#-----------------------------------------------------------------------------
198
9fae7483
CD
199## name For loop
200## failures 0
201## cut
202
e1a212fa 203for ($x, 'x', @y, 1, ) {
9fae7483
CD
204 print;
205}
206
207#-----------------------------------------------------------------------------
208
b34e4aff
CD
209## name qw<>
210## failures 0
211## cut
212
213@list = qw<1, 2, 3>; # this really means @list = ('1,', '2,', '3');
214
215#-----------------------------------------------------------------------------
216
72c43035 217## name original RT #27654
b6bc38d4
ES
218## failures 0
219## cut
220
221my @arr1;
222@arr1 = split /b/, 'abc';
223
224#-----------------------------------------------------------------------------
225
72c43035
ES
226## name RT #27654 - NKH example 1
227## failures 0
228## cut
229
230return
231 {
232 "string" => $aliased_history,
233 TIME => $self->{something},
234 } ;
235
236#-----------------------------------------------------------------------------
237
c87d8e37
ES
238## name RT #27654 - NKH example 2 - without allow_last_statement_to_be_comma_separated_in_map_and_grep
239## failures 1
240## cut
241
242%hash = map {$_, 1} @list ;
243
244#-----------------------------------------------------------------------------
245
246## name RT #27654 - NKH example 2 - with allow_last_statement_to_be_comma_separated_in_map_and_grep
72c43035 247## failures 0
c87d8e37 248## parms { allow_last_statement_to_be_comma_separated_in_map_and_grep => 1 }
72c43035
ES
249## cut
250
251%hash = map {$_, 1} @list ;
252
253#-----------------------------------------------------------------------------
254
255## name RT #27654 - NKH example 3
256## failures 0
c87d8e37 257## TODO PPI parses this code as blocks and not hash constructors.
72c43035
ES
258## cut
259
260$self->DoSomething
261 (
262 { %{$a_hash_ref}, %{$another_hash_ref}},
263 @more_data,
264 ) ;
265
266#-----------------------------------------------------------------------------
267
3beeb9e7 268## name RT #33935 and 49679
9f662e12
KH
269## failures 0
270## cut
271
272func( @{ $href }{'1', '2'} );
273
274#-----------------------------------------------------------------------------
275
45a557b1
TW
276## name RT #61301 (requires PPI 1.215)
277## failures 0
278## cut
279
280sub foo {
281 return { bar => 1, answer => 42 };
282}
283
284#-----------------------------------------------------------------------------
285
9502a80b
TW
286## name RT #64132 (requires PPI 1.215)
287## failures 0
288## cut
289
290sub new {
291 return bless { foo => 1, bar => 2 }, __PACKAGE__;
292}
293
294#-----------------------------------------------------------------------------
295
c948abe5
ES
296##############################################################################
297# $URL$
298# $Date$
299# $Author$
300# $Revision$
301##############################################################################
302
303# Local Variables:
304# mode: cperl
305# cperl-indent-level: 4
306# fill-column: 78
307# indent-tabs-mode: nil
308# c-indentation-style: bsd
309# End:
96fed375 310# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :