This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix common assign issue on @a = (split(), 1)
[perl5.git] / t / perf / benchmarks
CommitLineData
24fb648d
DM
1#!perl
2
9e7973fa 3# This file specifies an array-of-hashes that define snippets of code that
24fb648d
DM
4# can be run by various measurement and profiling tools.
5#
6# The basic idea is that any time you add an optimisation that is intended
7# to make a particular construct faster, then you should add that construct
8# to this file.
9#
10# Under the normal test suite, the test file benchmarks.t does a basic
11# compile and run of each of these snippets; not to test performance,
12# but just to ensure that the code doesn't have errors.
13#
14# Over time, it is intended that various measurement and profiling tools
15# will be written that can run selected (or all) snippets in various
16# environments. These will not be run as part of a normal test suite run.
17#
9e7973fa
DM
18# It is intended that the tests in this file will be lightweight; e.g.
19# a hash access, an empty function call, or a single regex match etc.
20#
24fb648d
DM
21# This file is designed to be read in by 'do' (and in such a way that
22# multiple versions of this file from different releases can be read in
23# by a single process).
24#
9e7973fa
DM
25# The top-level array has name/hash pairs (we use an array rather than a
26# hash so that duplicate keys can be spotted) Each name is a token that
27# describes a particular test. Code will be compiled in the package named
28# after the token, so it should match /^(\w|::)+$/a. It is intended that
29# this can be used on the command line of tools to select particular
30# tests.
31# In addition, the package names are arranged into an informal hierarchy
32# whose top members are (this is subject to change):
33#
34# call:: subroutine and method handling
35# expr:: expressions: e.g. $x=1, $foo{bar}[0]
84721d61 36# func:: perl functions, e.g. func::sort::...
9e7973fa
DM
37# loop:: structural code like for, while(), etc
38# regex:: regular expressions
39# string:: string handling
24fb648d 40#
9e7973fa
DM
41#
42# Each hash has three fields:
24fb648d
DM
43#
44# desc is a description of the test
45# setup is a string containing setup code
46# code is a string containing the code to run in a loop
47#
48# So typically a benchmark tool might do something like
49#
50# eval "package $token; $setup; for (1..1000000) { $code }"
9e7973fa
DM
51#
52# Currently the only tool that uses this file is Porting/bench.pl;
53# try C<perl Porting/bench.pl --help> for more info
24fb648d
DM
54
55
9e7973fa 56[
e800e134
DM
57 'call::sub::empty' => {
58 desc => 'function call with no args or body',
59 setup => 'sub f { }',
60 code => 'f()',
61 },
f7a874b8
DM
62 'call::sub::amp_empty' => {
63 desc => '&foo function call with no args or body',
64 setup => 'sub f { }; @_ = ();',
65 code => '&f',
66 },
e800e134 67 'call::sub::args3' => {
9e7973fa 68 desc => 'function call with 3 local lexical vars',
e800e134
DM
69 setup => 'sub f { my ($a, $b, $c) = @_; 1 }',
70 code => 'f(1,2,3)',
71 },
f7a874b8
DM
72 'call::sub::args2_ret1' => {
73 desc => 'function call with 2 local lex vars and 1 return value',
74 setup => 'my $x; sub f { my ($a, $b) = @_; $a+$b }',
75 code => '$x = f(1,2)',
76 },
77 'call::sub::args2_ret1temp' => {
78 desc => 'function call with 2 local lex vars and 1 return TEMP value',
79 setup => 'my $x; sub f { my ($a, $b) = @_; \$a }',
80 code => '$x = f(1,2)',
81 },
e800e134
DM
82 'call::sub::args3_ret3' => {
83 desc => 'function call with 3 local lex vars and 3 return values',
84 setup => 'my @a; sub f { my ($a, $b, $c) = @_; $a+$b, $c, 1 }',
85 code => '@a = f(1,2,3)',
86 },
f7a874b8
DM
87 'call::sub::args3_ret3str' => {
88 desc => 'function call with 3 local lex vars and 3 string return values',
89 setup => 'my @a; sub f { my ($a, $b, $c) = @_; my @s = ("aa","bb","cc"); @s }',
90 code => '@a = f(1,2,3)',
91 },
92 'call::sub::args3_ret3temp' => {
93 desc => 'function call with 3 local lex vars and 3 TEMP return values',
94 setup => 'my @a; sub f { my ($a, $b, $c) = @_; 1..3 }',
95 code => '@a = f(1,2,3)',
96 },
97 'call::sub::recursive' => {
98 desc => 'basic recursive function call',
99 setup => 'my $x; sub f { my ($i) = @_; $i > 0 ? $i + f($i-1) : 0 }',
100 code => '$x = f(1)',
101 },
e800e134
DM
102
103 'call::goto::empty' => {
104 desc => 'goto &funtion with no args or body',
105 setup => 'sub f { goto &g } sub g {}',
106 code => 'f()',
107 },
108 'call::goto::args3' => {
109 desc => 'goto &funtion with 3 local lexical vars',
110 setup => 'sub f { goto &g } sub g { my ($a, $b, $c) = @_ }',
9e7973fa
DM
111 code => 'f(1,2,3)',
112 },
113
fedf30e1
DM
114
115 'expr::array::lex_1const_0' => {
116 desc => 'lexical $array[0]',
117 setup => 'my @a = (1)',
118 code => '$a[0]',
119 },
120 'expr::array::lex_1const_m1' => {
121 desc => 'lexical $array[-1]',
122 setup => 'my @a = (1)',
123 code => '$a[-1]',
124 },
125 'expr::array::lex_2const' => {
126 desc => 'lexical $array[const][const]',
127 setup => 'my @a = ([1,2])',
128 code => '$a[0][1]',
129 },
130 'expr::array::lex_2var' => {
131 desc => 'lexical $array[$i1][$i2]',
132 setup => 'my ($i1,$i2) = (0,1); my @a = ([1,2])',
133 code => '$a[$i1][$i2]',
134 },
135 'expr::array::ref_lex_2var' => {
136 desc => 'lexical $arrayref->[$i1][$i2]',
137 setup => 'my ($i1,$i2) = (0,1); my $r = [[1,2]]',
138 code => '$r->[$i1][$i2]',
139 },
140 'expr::array::ref_lex_3const' => {
141 desc => 'lexical $arrayref->[const][const][const]',
142 setup => 'my $r = [[[1,2]]]',
143 code => '$r->[0][0][0]',
144 },
145 'expr::array::ref_expr_lex_3const' => {
146 desc => '(lexical expr)->[const][const][const]',
147 setup => 'my $r = [[[1,2]]]',
92792a1c 148 code => '($r||0)->[0][0][0]',
fedf30e1
DM
149 },
150
151
152 'expr::array::pkg_1const_0' => {
153 desc => 'package $array[0]',
92792a1c 154 setup => '@a = (1)',
fedf30e1
DM
155 code => '$a[0]',
156 },
157 'expr::array::pkg_1const_m1' => {
158 desc => 'package $array[-1]',
92792a1c 159 setup => '@a = (1)',
fedf30e1
DM
160 code => '$a[-1]',
161 },
162 'expr::array::pkg_2const' => {
163 desc => 'package $array[const][const]',
92792a1c 164 setup => '@a = ([1,2])',
fedf30e1
DM
165 code => '$a[0][1]',
166 },
167 'expr::array::pkg_2var' => {
168 desc => 'package $array[$i1][$i2]',
92792a1c 169 setup => '($i1,$i2) = (0,1); @a = ([1,2])',
fedf30e1
DM
170 code => '$a[$i1][$i2]',
171 },
172 'expr::array::ref_pkg_2var' => {
173 desc => 'package $arrayref->[$i1][$i2]',
92792a1c 174 setup => '($i1,$i2) = (0,1); $r = [[1,2]]',
fedf30e1
DM
175 code => '$r->[$i1][$i2]',
176 },
177 'expr::array::ref_pkg_3const' => {
178 desc => 'package $arrayref->[const][const][const]',
92792a1c 179 setup => '$r = [[[1,2]]]',
fedf30e1
DM
180 code => '$r->[0][0][0]',
181 },
182 'expr::array::ref_expr_pkg_3const' => {
183 desc => '(package expr)->[const][const][const]',
92792a1c
DM
184 setup => '$r = [[[1,2]]]',
185 code => '($r||0)->[0][0][0]',
fedf30e1
DM
186 },
187
188
189 'expr::arrayhash::lex_3var' => {
190 desc => 'lexical $h{$k1}[$i]{$k2}',
191 setup => 'my ($i, $k1, $k2) = (0,"foo","bar");'
192 . 'my %h = (foo => [ { bar => 1 } ])',
193 code => '$h{$k1}[$i]{$k2}',
194 },
195 'expr::arrayhash::pkg_3var' => {
196 desc => 'package $h{$k1}[$i]{$k2}',
92792a1c
DM
197 setup => '($i, $k1, $k2) = (0,"foo","bar");'
198 . '%h = (foo => [ { bar => 1 } ])',
fedf30e1
DM
199 code => '$h{$k1}[$i]{$k2}',
200 },
201
202
478d54a9 203 'expr::assign::scalar_lex_int' => {
9e7973fa
DM
204 desc => 'lexical $x = 1',
205 setup => 'my $x',
206 code => '$x = 1',
207 },
478d54a9
DM
208 'expr::assign::scalar_lex_str' => {
209 desc => 'lexical $x = "abc"',
210 setup => 'my $x',
211 code => '$x = "abc"',
212 },
213 'expr::assign::scalar_lex_strint' => {
214 desc => 'lexical $x = 1 where $x was previously a string',
215 setup => 'my $x = "abc"',
216 code => '$x = 1',
217 },
218 'expr::assign::scalar_lex_intstr' => {
219 desc => 'lexical $x = "abc" where $x was previously an int',
220 setup => 'my $x = 1;',
221 code => '$x = "abc"',
222 },
9e7973fa
DM
223 'expr::assign::2list_lex' => {
224 desc => 'lexical ($x, $y) = (1, 2)',
225 setup => 'my ($x, $y)',
226 code => '($x, $y) = (1, 2)',
24fb648d 227 },
15c41403 228
fedf30e1
DM
229
230 'expr::hash::lex_1const' => {
231 desc => 'lexical $hash{const}',
232 setup => 'my %h = ("foo" => 1)',
233 code => '$h{foo}',
234 },
235 'expr::hash::lex_2const' => {
236 desc => 'lexical $hash{const}{const}',
237 setup => 'my %h = (foo => { bar => 1 })',
238 code => '$h{foo}{bar}',
239 },
240 'expr::hash::lex_2var' => {
241 desc => 'lexical $hash{$k1}{$k2}',
242 setup => 'my ($k1,$k2) = qw(foo bar); my %h = ($k1 => { $k2 => 1 })',
243 code => '$h{$k1}{$k2}',
244 },
245 'expr::hash::ref_lex_2var' => {
246 desc => 'lexical $hashref->{$k1}{$k2}',
247 setup => 'my ($k1,$k2) = qw(foo bar); my $r = {$k1 => { $k2 => 1 }}',
248 code => '$r->{$k1}{$k2}',
249 },
250 'expr::hash::ref_lex_3const' => {
251 desc => 'lexical $hashref->{const}{const}{const}',
252 setup => 'my $r = {foo => { bar => { baz => 1 }}}',
253 code => '$r->{foo}{bar}{baz}',
254 },
255 'expr::hash::ref_expr_lex_3const' => {
256 desc => '(lexical expr)->{const}{const}{const}',
257 setup => 'my $r = {foo => { bar => { baz => 1 }}}',
92792a1c 258 code => '($r||0)->{foo}{bar}{baz}',
fedf30e1
DM
259 },
260
261
262 'expr::hash::pkg_1const' => {
263 desc => 'package $hash{const}',
92792a1c 264 setup => '%h = ("foo" => 1)',
fedf30e1
DM
265 code => '$h{foo}',
266 },
267 'expr::hash::pkg_2const' => {
268 desc => 'package $hash{const}{const}',
92792a1c 269 setup => '%h = (foo => { bar => 1 })',
fedf30e1
DM
270 code => '$h{foo}{bar}',
271 },
272 'expr::hash::pkg_2var' => {
273 desc => 'package $hash{$k1}{$k2}',
92792a1c 274 setup => '($k1,$k2) = qw(foo bar); %h = ($k1 => { $k2 => 1 })',
fedf30e1
DM
275 code => '$h{$k1}{$k2}',
276 },
277 'expr::hash::ref_pkg_2var' => {
278 desc => 'package $hashref->{$k1}{$k2}',
92792a1c 279 setup => '($k1,$k2) = qw(foo bar); $r = {$k1 => { $k2 => 1 }}',
fedf30e1
DM
280 code => '$r->{$k1}{$k2}',
281 },
282 'expr::hash::ref_pkg_3const' => {
283 desc => 'package $hashref->{const}{const}{const}',
92792a1c 284 setup => '$r = {foo => { bar => { baz => 1 }}}',
fedf30e1
DM
285 code => '$r->{foo}{bar}{baz}',
286 },
287 'expr::hash::ref_expr_pkg_3const' => {
288 desc => '(package expr)->{const}{const}{const}',
92792a1c
DM
289 setup => '$r = {foo => { bar => { baz => 1 }}}',
290 code => '($r||0)->{foo}{bar}{baz}',
fedf30e1
DM
291 },
292
293
294 'expr::hash::exists_lex_2var' => {
295 desc => 'lexical exists $hash{$k1}{$k2}',
296 setup => 'my ($k1,$k2) = qw(foo bar); my %h = ($k1 => { $k2 => 1 });',
297 code => 'exists $h{$k1}{$k2}',
298 },
299 'expr::hash::delete_lex_2var' => {
300 desc => 'lexical delete $hash{$k1}{$k2}',
301 setup => 'my ($k1,$k2) = qw(foo bar); my %h = ($k1 => { $k2 => 1 });',
302 code => 'delete $h{$k1}{$k2}',
303 },
304
305
147f21b5
DM
306 # using a const string as second arg to index triggers using FBM.
307 # the FBM matcher special-cases 1,2-byte strings.
308 #
309 'expr::index::short_const1' => {
310 desc => 'index of a short string against a 1 char const substr',
311 setup => 'my $x = "aaaab"',
312 code => 'index $x, "b"',
313 },
314 'expr::index::long_const1' => {
315 desc => 'index of a long string against a 1 char const substr',
316 setup => 'my $x = "a" x 1000 . "b"',
317 code => 'index $x, "b"',
318 },
319 'expr::index::short_const2aabc_bc' => {
320 desc => 'index of a short string against a 2 char const substr',
321 setup => 'my $x = "aaaabc"',
322 code => 'index $x, "bc"',
323 },
324 'expr::index::long_const2aabc_bc' => {
325 desc => 'index of a long string against a 2 char const substr',
326 setup => 'my $x = "a" x 1000 . "bc"',
327 code => 'index $x, "bc"',
328 },
329 'expr::index::long_const2aa_ab' => {
330 desc => 'index of a long string aaa.. against const substr "ab"',
331 setup => 'my $x = "a" x 1000',
332 code => 'index $x, "ab"',
333 },
334 'expr::index::long_const2bb_ab' => {
335 desc => 'index of a long string bbb.. against const substr "ab"',
336 setup => 'my $x = "b" x 1000',
337 code => 'index $x, "ab"',
338 },
339 'expr::index::long_const2aa_bb' => {
340 desc => 'index of a long string aaa.. against const substr "bb"',
341 setup => 'my $x = "a" x 1000',
342 code => 'index $x, "bb"',
343 },
344 # this one is designed to be pathological
345 'expr::index::long_const2ab_aa' => {
346 desc => 'index of a long string abab.. against const substr "aa"',
347 setup => 'my $x = "ab" x 500',
348 code => 'index $x, "aa"',
349 },
350 # near misses with gaps, 1st letter
351 'expr::index::long_const2aaxx_xy' => {
352 desc => 'index of a long string with "xx"s against const substr "xy"',
353 setup => 'my $x = "aaaaaaaaxx" x 100',
354 code => 'index $x, "xy"',
355 },
356 # near misses with gaps, 2nd letter
357 'expr::index::long_const2aayy_xy' => {
358 desc => 'index of a long string with "yy"s against const substr "xy"',
359 setup => 'my $x = "aaaaaaaayy" x 100',
360 code => 'index $x, "xy"',
361 },
362 # near misses with gaps, duplicate letter
363 'expr::index::long_const2aaxy_xx' => {
364 desc => 'index of a long string with "xy"s against const substr "xx"',
365 setup => 'my $x = "aaaaaaaaxy" x 100',
366 code => 'index $x, "xx"',
367 },
368 # alternating near misses with gaps
369 'expr::index::long_const2aaxxaayy_xy' => {
370 desc => 'index of a long string with "xx/yy"s against const substr "xy"',
371 setup => 'my $x = "aaaaaaaaxxbbbbbbbbyy" x 50',
372 code => 'index $x, "xy"',
373 },
374 'expr::index::short_const3aabcd_bcd' => {
375 desc => 'index of a short string against a 3 char const substr',
376 setup => 'my $x = "aaaabcd"',
377 code => 'index $x, "bcd"',
378 },
379 'expr::index::long_const3aabcd_bcd' => {
380 desc => 'index of a long string against a 3 char const substr',
381 setup => 'my $x = "a" x 1000 . "bcd"',
382 code => 'index $x, "bcd"',
383 },
384 'expr::index::long_const3ab_abc' => {
385 desc => 'index of a long string of "ab"s against a 3 char const substr "abc"',
386 setup => 'my $x = "ab" x 500',
387 code => 'index $x, "abc"',
388 },
389 'expr::index::long_const3bc_abc' => {
390 desc => 'index of a long string of "bc"s against a 3 char const substr "abc"',
391 setup => 'my $x = "bc" x 500',
392 code => 'index $x, "abc"',
393 },
41f678d9 394 'expr::index::utf8_position_1' => {
15c41403 395 desc => 'index of a utf8 string, matching at position 1',
92792a1c 396 setup => 'my $x = "abc". chr(0x100); chop $x',
15c41403
JR
397 code => 'index $x, "b"',
398 },
24fb648d 399
a5f48505
DM
400
401 # list assign, OP_AASSIGN
402
403
404 # (....) = ()
405
406 'expr::aassign::ma_empty' => {
407 desc => 'my array assigned empty',
408 setup => '',
409 code => 'my @a = ()',
410 },
411 'expr::aassign::lax_empty' => {
412 desc => 'non-empty lexical array assigned empty',
413 setup => 'my @a = 1..3;',
414 code => '@a = ()',
415 },
416 'expr::aassign::llax_empty' => {
417 desc => 'non-empty lexical var and array assigned empty',
418 setup => 'my ($x, @a) = 1..4;',
419 code => '($x, @a) = ()',
420 },
421 'expr::aassign::3m_empty' => {
422 desc => 'three my vars assigned empty',
423 setup => '',
424 code => 'my ($x,$y,$z) = ()',
425 },
426 'expr::aassign::3l_empty' => {
427 desc => 'three lexical vars assigned empty',
428 setup => 'my ($x,$y,$z)',
429 code => '($x,$y,$z) = ()',
430 },
431 'expr::aassign::pa_empty' => {
432 desc => 'package array assigned empty',
433 setup => '',
434 code => '@a = ()',
435 },
436 'expr::aassign::pax_empty' => {
437 desc => 'non-empty package array assigned empty',
438 setup => '@a = (1,2,3)',
439 code => '@a = ()',
440 },
441 'expr::aassign::3p_empty' => {
442 desc => 'three package vars assigned empty',
443 setup => '($x,$y,$z) = 1..3;',
444 code => '($x,$y,$z) = ()',
445 },
446
447 # (....) = (1,2,3)
448
449 'expr::aassign::ma_3c' => {
450 desc => 'my array assigned 3 consts',
451 setup => '',
452 code => 'my @a = (1,2,3)',
453 },
454 'expr::aassign::lax_3c' => {
455 desc => 'non-empty lexical array assigned 3 consts',
456 setup => 'my @a = 1..3;',
457 code => '@a = (1,2,3)',
458 },
459 'expr::aassign::llax_3c' => {
460 desc => 'non-empty lexical var and array assigned 3 consts',
461 setup => 'my ($x, @a) = 1..4;',
462 code => '($x, @a) = (1,2,3)',
463 },
464 'expr::aassign::3m_3c' => {
465 desc => 'three my vars assigned 3 consts',
466 setup => '',
467 code => 'my ($x,$y,$z) = (1,2,3)',
468 },
469 'expr::aassign::3l_3c' => {
470 desc => 'three lexical vars assigned 3 consts',
471 setup => 'my ($x,$y,$z)',
472 code => '($x,$y,$z) = (1,2,3)',
473 },
474 'expr::aassign::pa_3c' => {
475 desc => 'package array assigned 3 consts',
476 setup => '',
477 code => '@a = (1,2,3)',
478 },
479 'expr::aassign::pax_3c' => {
480 desc => 'non-empty package array assigned 3 consts',
481 setup => '@a = (1,2,3)',
482 code => '@a = (1,2,3)',
483 },
484 'expr::aassign::3p_3c' => {
485 desc => 'three package vars assigned 3 consts',
486 setup => '($x,$y,$z) = 1..3;',
487 code => '($x,$y,$z) = (1,2,3)',
488 },
489
490 # (....) = @lexical
491
492 'expr::aassign::ma_la' => {
493 desc => 'my array assigned lexical array',
494 setup => 'my @init = 1..3;',
495 code => 'my @a = @init',
496 },
497 'expr::aassign::lax_la' => {
498 desc => 'non-empty lexical array assigned lexical array',
499 setup => 'my @init = 1..3; my @a = 1..3;',
500 code => '@a = @init',
501 },
502 'expr::aassign::llax_la' => {
503 desc => 'non-empty lexical var and array assigned lexical array',
504 setup => 'my @init = 1..3; my ($x, @a) = 1..4;',
505 code => '($x, @a) = @init',
506 },
507 'expr::aassign::3m_la' => {
508 desc => 'three my vars assigned lexical array',
509 setup => 'my @init = 1..3;',
510 code => 'my ($x,$y,$z) = @init',
511 },
512 'expr::aassign::3l_la' => {
513 desc => 'three lexical vars assigned lexical array',
514 setup => 'my @init = 1..3; my ($x,$y,$z)',
515 code => '($x,$y,$z) = @init',
516 },
517 'expr::aassign::pa_la' => {
518 desc => 'package array assigned lexical array',
519 setup => 'my @init = 1..3;',
520 code => '@a = @init',
521 },
522 'expr::aassign::pax_la' => {
523 desc => 'non-empty package array assigned lexical array',
524 setup => 'my @init = 1..3; @a = @init',
525 code => '@a = @init',
526 },
527 'expr::aassign::3p_la' => {
528 desc => 'three package vars assigned lexical array',
529 setup => 'my @init = 1..3; ($x,$y,$z) = 1..3;',
530 code => '($x,$y,$z) = @init',
531 },
532
533 # (....) = @package
534
535 'expr::aassign::ma_pa' => {
536 desc => 'my array assigned package array',
537 setup => '@init = 1..3;',
538 code => 'my @a = @init',
539 },
540 'expr::aassign::lax_pa' => {
541 desc => 'non-empty lexical array assigned package array',
542 setup => '@init = 1..3; my @a = 1..3;',
543 code => '@a = @init',
544 },
545 'expr::aassign::llax_pa' => {
546 desc => 'non-empty lexical var and array assigned package array',
547 setup => '@init = 1..3; my ($x, @a) = 1..4;',
548 code => '($x, @a) = @init',
549 },
550 'expr::aassign::3m_pa' => {
551 desc => 'three my vars assigned package array',
552 setup => '@init = 1..3;',
553 code => 'my ($x,$y,$z) = @init',
554 },
555 'expr::aassign::3l_pa' => {
556 desc => 'three lexical vars assigned package array',
557 setup => '@init = 1..3; my ($x,$y,$z)',
558 code => '($x,$y,$z) = @init',
559 },
560 'expr::aassign::pa_pa' => {
561 desc => 'package array assigned package array',
562 setup => '@init = 1..3;',
563 code => '@a = @init',
564 },
565 'expr::aassign::pax_pa' => {
566 desc => 'non-empty package array assigned package array',
567 setup => '@init = 1..3; @a = @init',
568 code => '@a = @init',
569 },
570 'expr::aassign::3p_pa' => {
571 desc => 'three package vars assigned package array',
572 setup => '@init = 1..3; ($x,$y,$z) = 1..3;',
573 code => '($x,$y,$z) = @init',
574 },
575
576 # (....) = @_;
577
578 'expr::aassign::ma_defary' => {
579 desc => 'my array assigned @_',
580 setup => '@_ = 1..3;',
581 code => 'my @a = @_',
582 },
583 'expr::aassign::lax_defary' => {
584 desc => 'non-empty lexical array assigned @_',
585 setup => '@_ = 1..3; my @a = 1..3;',
586 code => '@a = @_',
587 },
588 'expr::aassign::llax_defary' => {
589 desc => 'non-empty lexical var and array assigned @_',
590 setup => '@_ = 1..3; my ($x, @a) = 1..4;',
591 code => '($x, @a) = @_',
592 },
593 'expr::aassign::3m_defary' => {
594 desc => 'three my vars assigned @_',
595 setup => '@_ = 1..3;',
596 code => 'my ($x,$y,$z) = @_',
597 },
598 'expr::aassign::3l_defary' => {
599 desc => 'three lexical vars assigned @_',
600 setup => '@_ = 1..3; my ($x,$y,$z)',
601 code => '($x,$y,$z) = @_',
602 },
603 'expr::aassign::pa_defary' => {
604 desc => 'package array assigned @_',
605 setup => '@_ = 1..3;',
606 code => '@a = @_',
607 },
608 'expr::aassign::pax_defary' => {
609 desc => 'non-empty package array assigned @_',
610 setup => '@_ = 1..3; @a = @_',
611 code => '@a = @_',
612 },
613 'expr::aassign::3p_defary' => {
614 desc => 'three package vars assigned @_',
615 setup => '@_ = 1..3; ($x,$y,$z) = 1..3;',
616 code => '($x,$y,$z) = @_',
617 },
618
619
620 # (....) = ($lex1,$lex2,$lex3);
621
622 'expr::aassign::ma_3l' => {
623 desc => 'my array assigned lexicals',
624 setup => 'my ($v1,$v2,$v3) = 1..3;',
625 code => 'my @a = ($v1,$v2,$v3)',
626 },
627 'expr::aassign::lax_3l' => {
628 desc => 'non-empty lexical array assigned lexicals',
629 setup => 'my ($v1,$v2,$v3) = 1..3; my @a = 1..3;',
630 code => '@a = ($v1,$v2,$v3)',
631 },
632 'expr::aassign::llax_3l' => {
633 desc => 'non-empty lexical var and array assigned lexicals',
634 setup => 'my ($v1,$v2,$v3) = 1..3; my ($x, @a) = 1..4;',
635 code => '($x, @a) = ($v1,$v2,$v3)',
636 },
637 'expr::aassign::3m_3l' => {
638 desc => 'three my vars assigned lexicals',
639 setup => 'my ($v1,$v2,$v3) = 1..3;',
640 code => 'my ($x,$y,$z) = ($v1,$v2,$v3)',
641 },
642 'expr::aassign::3l_3l' => {
643 desc => 'three lexical vars assigned lexicals',
644 setup => 'my ($v1,$v2,$v3) = 1..3; my ($x,$y,$z)',
645 code => '($x,$y,$z) = ($v1,$v2,$v3)',
646 },
647 'expr::aassign::pa_3l' => {
648 desc => 'package array assigned lexicals',
649 setup => 'my ($v1,$v2,$v3) = 1..3;',
650 code => '@a = ($v1,$v2,$v3)',
651 },
652 'expr::aassign::pax_3l' => {
653 desc => 'non-empty package array assigned lexicals',
654 setup => 'my ($v1,$v2,$v3) = 1..3; @a = @_',
655 code => '@a = ($v1,$v2,$v3)',
656 },
657 'expr::aassign::3p_3l' => {
658 desc => 'three package vars assigned lexicals',
659 setup => 'my ($v1,$v2,$v3) = 1..3; ($x,$y,$z) = 1..3;',
660 code => '($x,$y,$z) = ($v1,$v2,$v3)',
661 },
662
663
664 # (....) = ($pkg1,$pkg2,$pkg3);
665
666 'expr::aassign::ma_3p' => {
667 desc => 'my array assigned 3 package vars',
668 setup => '($v1,$v2,$v3) = 1..3;',
669 code => 'my @a = ($v1,$v2,$v3)',
670 },
671 'expr::aassign::lax_3p' => {
672 desc => 'non-empty lexical array assigned 3 package vars',
673 setup => '($v1,$v2,$v3) = 1..3; my @a = 1..3;',
674 code => '@a = ($v1,$v2,$v3)',
675 },
676 'expr::aassign::llax_3p' => {
677 desc => 'non-empty lexical var and array assigned 3 package vars',
678 setup => '($v1,$v2,$v3) = 1..3; my ($x, @a) = 1..4;',
679 code => '($x, @a) = ($v1,$v2,$v3)',
680 },
681 'expr::aassign::3m_3p' => {
682 desc => 'three my vars assigned 3 package vars',
683 setup => '($v1,$v2,$v3) = 1..3;',
684 code => 'my ($x,$y,$z) = ($v1,$v2,$v3)',
685 },
686 'expr::aassign::3l_3p' => {
687 desc => 'three lexical vars assigned 3 package vars',
688 setup => '($v1,$v2,$v3) = 1..3; my ($x,$y,$z)',
689 code => '($x,$y,$z) = ($v1,$v2,$v3)',
690 },
691 'expr::aassign::pa_3p' => {
692 desc => 'package array assigned 3 package vars',
693 setup => '($v1,$v2,$v3) = 1..3;',
694 code => '@a = ($v1,$v2,$v3)',
695 },
696 'expr::aassign::pax_3p' => {
697 desc => 'non-empty package array assigned 3 package vars',
698 setup => '($v1,$v2,$v3) = 1..3; @a = @_',
699 code => '@a = ($v1,$v2,$v3)',
700 },
701 'expr::aassign::3p_3p' => {
702 desc => 'three package vars assigned 3 package vars',
703 setup => '($v1,$v2,$v3) = 1..3; ($x,$y,$z) = 1..3;',
704 code => '($x,$y,$z) = ($v1,$v2,$v3)',
705 },
706
707
708 # (....) = (1,2,$shared);
709
710 'expr::aassign::llax_2c1s' => {
711 desc => 'non-empty lexical var and array assigned 2 consts and 1 shared var',
712 setup => 'my ($x, @a) = 1..4;',
713 code => '($x, @a) = (1,2,$x)',
714 },
715 'expr::aassign::3l_2c1s' => {
716 desc => 'three lexical vars assigned 2 consts and 1 shared var',
717 setup => 'my ($x,$y,$z) = 1..3;',
718 code => '($x,$y,$z) = (1,2,$x)',
719 },
720 'expr::aassign::3p_2c1s' => {
721 desc => 'three package vars assigned 2 consts and 1 shared var',
722 setup => '($x,$y,$z) = 1..3;',
723 code => '($x,$y,$z) = (1,2,$x)',
724 },
725
726
727 # ($a,$b) = ($b,$a);
728
729 'expr::aassign::2l_swap' => {
730 desc => 'swap two lexical vars',
731 setup => 'my ($a,$b) = (1,2)',
732 code => '($a,$b) = ($b,$a)',
733 },
734 'expr::aassign::2p_swap' => {
735 desc => 'swap two package vars',
736 setup => '($a,$b) = (1,2)',
737 code => '($a,$b) = ($b,$a)',
738 },
739 'expr::aassign::2laelem_swap' => {
740 desc => 'swap two lexical vars',
741 setup => 'my @a = (1,2)',
742 code => '($a[0],$a[1]) = ($a[1],$a[0])',
743 },
744
745 # misc list assign
746
747 'expr::aassign::5l_4l1s' => {
748 desc => 'long list of lexical vars, 1 shared',
749 setup => 'my ($a,$b,$c,$d,$e) = 1..5',
750 code => '($a,$b,$c,$d,$e) = ($a,$a,$c,$d,$e)',
751 },
752
753 'expr::aassign::5p_4p1s' => {
754 desc => 'long list of package vars, 1 shared',
755 setup => '($a,$b,$c,$d,$e) = 1..5',
756 code => '($a,$b,$c,$d,$e) = ($a,$a,$c,$d,$e)',
757 },
758 'expr::aassign::5l_defary' => {
759 desc => 'long list of lexical vars to assign @_ to',
760 setup => '@_ = 1..5',
761 code => 'my ($a,$b,$c,$d,$e) = @_',
762 },
763 'expr::aassign::5l1la_defary' => {
764 desc => 'long list of lexical vars plus long slurp to assign @_ to',
765 setup => '@_ = 1..20',
766 code => 'my ($a,$b,$c,$d,$e,@rest) = @_',
767 },
808ce557
DM
768 'expr::aassign::1l_2l' => {
769 desc => 'single lexical LHS',
770 setup => 'my $x = 1;',
771 code => '(undef,$x) = ($x,$x)',
772 },
773 'expr::aassign::2l_1l' => {
774 desc => 'single lexical RHS',
775 setup => 'my $x = 1;',
9ae0115f
DM
776 code => '($x,$x) = ($x)',
777 },
778 'expr::aassign::2l_1ul' => {
779 desc => 'undef and single lexical RHS',
780 setup => 'my $x = 1;',
808ce557
DM
781 code => '($x,$x) = (undef, $x)',
782 },
a5f48505
DM
783
784
230ee21f
DM
785 'expr::arith::add_lex_ii' => {
786 desc => 'add two integers and assign to a lexical var',
787 setup => 'my ($x,$y,$z) = 1..3;',
788 code => '$z = $x + $y',
789 },
790 'expr::arith::add_pkg_ii' => {
791 desc => 'add two integers and assign to a package var',
792 setup => 'my ($x,$y) = 1..2; $z = 3;',
793 code => '$z = $x + $y',
794 },
795 'expr::arith::add_lex_nn' => {
796 desc => 'add two NVs and assign to a lexical var',
797 setup => 'my ($x,$y,$z) = (1.1, 2.2, 3.3);',
798 code => '$z = $x + $y',
799 },
800 'expr::arith::add_pkg_nn' => {
801 desc => 'add two NVs and assign to a package var',
802 setup => 'my ($x,$y); ($x,$y,$z) = (1.1, 2.2, 3.3);',
803 code => '$z = $x + $y',
804 },
805 'expr::arith::add_lex_ni' => {
806 desc => 'add an int and an NV and assign to a lexical var',
807 setup => 'my ($x,$y,$z) = (1, 2.2, 3.3);',
808 code => '$z = $x + $y',
809 },
810 'expr::arith::add_pkg_ni' => {
811 desc => 'add an int and an NV and assign to a package var',
812 setup => 'my ($x,$y); ($x,$y,$z) = (1, 2.2, 3.3);',
813 code => '$z = $x + $y',
814 },
80e5abf2
DM
815 'expr::arith::add_lex_ss' => {
816 desc => 'add two short strings and assign to a lexical var',
817 setup => 'my ($x,$y,$z) = ("1", "2", 1);',
818 code => '$z = $x + $y; $x = "1"; ',
819 },
820
821 'expr::arith::add_lex_ll' => {
822 desc => 'add two long strings and assign to a lexical var',
823 setup => 'my ($x,$y,$z) = ("12345", "23456", 1);',
824 code => '$z = $x + $y; $x = "12345"; ',
825 },
230ee21f
DM
826
827 'expr::arith::sub_lex_ii' => {
828 desc => 'subtract two integers and assign to a lexical var',
829 setup => 'my ($x,$y,$z) = 1..3;',
830 code => '$z = $x - $y',
831 },
832 'expr::arith::sub_pkg_ii' => {
833 desc => 'subtract two integers and assign to a package var',
834 setup => 'my ($x,$y) = 1..2; $z = 3;',
835 code => '$z = $x - $y',
836 },
837 'expr::arith::sub_lex_nn' => {
838 desc => 'subtract two NVs and assign to a lexical var',
839 setup => 'my ($x,$y,$z) = (1.1, 2.2, 3.3);',
840 code => '$z = $x - $y',
841 },
842 'expr::arith::sub_pkg_nn' => {
843 desc => 'subtract two NVs and assign to a package var',
844 setup => 'my ($x,$y); ($x,$y,$z) = (1.1, 2.2, 3.3);',
845 code => '$z = $x - $y',
846 },
847 'expr::arith::sub_lex_ni' => {
848 desc => 'subtract an int and an NV and assign to a lexical var',
849 setup => 'my ($x,$y,$z) = (1, 2.2, 3.3);',
850 code => '$z = $x - $y',
851 },
852 'expr::arith::sub_pkg_ni' => {
853 desc => 'subtract an int and an NV and assign to a package var',
854 setup => 'my ($x,$y); ($x,$y,$z) = (1, 2.2, 3.3);',
855 code => '$z = $x - $y',
856 },
857
858 'expr::arith::mult_lex_ii' => {
859 desc => 'multiply two integers and assign to a lexical var',
860 setup => 'my ($x,$y,$z) = 1..3;',
861 code => '$z = $x * $y',
862 },
863 'expr::arith::mult_pkg_ii' => {
864 desc => 'multiply two integers and assign to a package var',
865 setup => 'my ($x,$y) = 1..2; $z = 3;',
866 code => '$z = $x * $y',
867 },
868 'expr::arith::mult_lex_nn' => {
869 desc => 'multiply two NVs and assign to a lexical var',
870 setup => 'my ($x,$y,$z) = (1.1, 2.2, 3.3);',
871 code => '$z = $x * $y',
872 },
873 'expr::arith::mult_pkg_nn' => {
874 desc => 'multiply two NVs and assign to a package var',
875 setup => 'my ($x,$y); ($x,$y,$z) = (1.1, 2.2, 3.3);',
876 code => '$z = $x * $y',
877 },
878 'expr::arith::mult_lex_ni' => {
879 desc => 'multiply an int and an NV and assign to a lexical var',
880 setup => 'my ($x,$y,$z) = (1, 2.2, 3.3);',
881 code => '$z = $x * $y',
882 },
883 'expr::arith::mult_pkg_ni' => {
884 desc => 'multiply an int and an NV and assign to a package var',
885 setup => 'my ($x,$y); ($x,$y,$z) = (1, 2.2, 3.3);',
886 code => '$z = $x * $y',
887 },
888
4c2c3128
DM
889 'expr::arith::preinc' => {
890 desc => '++$x',
891 setup => 'my $x = 1;',
892 code => '++$x',
893 },
894 'expr::arith::predec' => {
895 desc => '--$x',
896 setup => 'my $x = 1;',
897 code => '--$x',
898 },
899 'expr::arith::postinc' => {
900 desc => '$x++',
901 setup => 'my $x = 1; my $y',
902 code => '$y = $x++', # scalar context so not optimised to ++$x
903 },
904 'expr::arith::postdec' => {
905 desc => '$x--',
906 setup => 'my $x = 1; my $y',
907 code => '$y = $x--', # scalar context so not optimised to --$x
b52de964
DM
908 },
909
84721d61 910
5012eebe 911
84721d61
DM
912 'func::sort::num' => {
913 desc => 'plain numeric sort',
914 setup => 'my (@a, @b); @a = reverse 1..10;',
915 code => '@b = sort { $a <=> $b } @a',
916 },
917 'func::sort::num_block' => {
918 desc => 'codeblock numeric sort',
919 setup => 'my (@a, @b); @a = reverse 1..10;',
920 code => '@b = sort { $a + 1 <=> $b + 1 } @a',
921 },
922 'func::sort::num_fn' => {
923 desc => 'function numeric sort',
924 setup => 'sub f { $a + 1 <=> $b + 1 } my (@a, @b); @a = reverse 1..10;',
925 code => '@b = sort f @a',
926 },
927 'func::sort::str' => {
928 desc => 'plain string sort',
929 setup => 'my (@a, @b); @a = reverse "a".."j";',
930 code => '@b = sort { $a cmp $b } @a',
931 },
932 'func::sort::str_block' => {
933 desc => 'codeblock string sort',
934 setup => 'my (@a, @b); @a = reverse "a".."j";',
935 code => '@b = sort { ($a . "") cmp ($b . "") } @a',
936 },
937 'func::sort::str_fn' => {
938 desc => 'function string sort',
939 setup => 'sub f { ($a . "") cmp ($b . "") } my (@a, @b); @a = reverse "a".."j";',
940 code => '@b = sort f @a',
941 },
942
943 'func::sort::num_inplace' => {
944 desc => 'plain numeric sort in-place',
945 setup => 'my @a = reverse 1..10;',
946 code => '@a = sort { $a <=> $b } @a',
947 },
948 'func::sort::num_block_inplace' => {
949 desc => 'codeblock numeric sort in-place',
950 setup => 'my @a = reverse 1..10;',
951 code => '@a = sort { $a + 1 <=> $b + 1 } @a',
952 },
953 'func::sort::num_fn_inplace' => {
954 desc => 'function numeric sort in-place',
955 setup => 'sub f { $a + 1 <=> $b + 1 } my @a = reverse 1..10;',
956 code => '@a = sort f @a',
957 },
958 'func::sort::str_inplace' => {
959 desc => 'plain string sort in-place',
960 setup => 'my @a = reverse "a".."j";',
961 code => '@a = sort { $a cmp $b } @a',
962 },
963 'func::sort::str_block_inplace' => {
964 desc => 'codeblock string sort in-place',
965 setup => 'my @a = reverse "a".."j";',
966 code => '@a = sort { ($a . "") cmp ($b . "") } @a',
967 },
968 'func::sort::str_fn_inplace' => {
969 desc => 'function string sort in-place',
970 setup => 'sub f { ($a . "") cmp ($b . "") } my @a = reverse "a".."j";',
971 code => '@a = sort f @a',
972 },
973
974
5012eebe
DM
975 'func::split::vars' => {
976 desc => 'split into two lexical vars',
977 setup => 'my $s = "abc:def";',
978 code => 'my ($x, $y) = split /:/, $s, 2;',
979 },
980
981 'func::split::array' => {
982 desc => 'split into a lexical array',
983 setup => 'my @a; my $s = "abc:def";',
984 code => '@a = split /:/, $s, 2;',
985 },
5012eebe
DM
986 'func::split::myarray' => {
987 desc => 'split into a lexical array declared in the assign',
988 setup => 'my $s = "abc:def";',
989 code => 'my @a = split /:/, $s, 2;',
990 },
692044df
DM
991 'func::split::arrayexpr' => {
992 desc => 'split into an @{$expr} ',
993 setup => 'my $s = "abc:def"; my $r = []',
994 code => '@$r = split /:/, $s, 2;',
995 },
47a8f19b
DM
996 'func::split::arraylist' => {
997 desc => 'split into an array with extra arg',
998 setup => 'my @a; my $s = "abc:def";',
999 code => '@a = (split(/:/, $s, 2), 1);',
1000 },
5012eebe
DM
1001
1002
aedeb7c2
DM
1003 'loop::block' => {
1004 desc => 'empty basic loop',
84721d61 1005 setup => '',
aedeb7c2
DM
1006 code => '{1;}',
1007 },
1008
1009 'loop::do' => {
1010 desc => 'basic do block',
1011 setup => 'my $x; my $y = 2;',
1012 code => '$x = do {1; $y}', # the ';' stops the do being optimised
1013 },
1014
1015 'loop::for::my_range1' => {
1016 desc => 'empty for loop with my var and 1 integer range',
1017 setup => '',
1018 code => 'for my $x (1..1) {}',
1019 },
1020 'loop::for::lex_range1' => {
1021 desc => 'empty for loop with lexical var and 1 integer range',
1022 setup => 'my $x;',
1023 code => 'for $x (1..1) {}',
1024 },
1025 'loop::for::pkg_range1' => {
1026 desc => 'empty for loop with package var and 1 integer range',
1027 setup => '$x = 1;',
1028 code => 'for $x (1..1) {}',
1029 },
1030 'loop::for::defsv_range1' => {
1031 desc => 'empty for loop with $_ and integer 1 range',
1032 setup => ';',
1033 code => 'for (1..1) {}',
1034 },
1035 'loop::for::my_range4' => {
1036 desc => 'empty for loop with my var and 4 integer range',
1037 setup => '',
1038 code => 'for my $x (1..4) {}',
1039 },
1040 'loop::for::lex_range4' => {
1041 desc => 'empty for loop with lexical var and 4 integer range',
1042 setup => 'my $x;',
1043 code => 'for $x (1..4) {}',
1044 },
1045 'loop::for::pkg_range4' => {
1046 desc => 'empty for loop with package var and 4 integer range',
1047 setup => '$x = 1;',
1048 code => 'for $x (1..4) {}',
1049 },
1050 'loop::for::defsv_range4' => {
1051 desc => 'empty for loop with $_ and integer 4 range',
1052 setup => ';',
1053 code => 'for (1..4) {}',
1054 },
4c2c3128 1055
aedeb7c2
DM
1056 'loop::for::my_list1' => {
1057 desc => 'empty for loop with my var and 1 integer list',
b52de964 1058 setup => '',
aedeb7c2
DM
1059 code => 'for my $x (1) {}',
1060 },
1061 'loop::for::lex_list1' => {
1062 desc => 'empty for loop with lexical var and 1 integer list',
1063 setup => 'my $x;',
1064 code => 'for $x (1) {}',
1065 },
1066 'loop::for::pkg_list1' => {
1067 desc => 'empty for loop with package var and 1 integer list',
1068 setup => '$x = 1;',
1069 code => 'for $x (1) {}',
1070 },
1071 'loop::for::defsv_list1' => {
1072 desc => 'empty for loop with $_ and integer 1 list',
1073 setup => ';',
1074 code => 'for (1) {}',
1075 },
1076 'loop::for::my_list4' => {
1077 desc => 'empty for loop with my var and 4 integer list',
1078 setup => '',
1079 code => 'for my $x (1,2,3,4) {}',
1080 },
1081 'loop::for::lex_list4' => {
1082 desc => 'empty for loop with lexical var and 4 integer list',
1083 setup => 'my $x;',
1084 code => 'for $x (1,2,3,4) {}',
1085 },
1086 'loop::for::pkg_list4' => {
1087 desc => 'empty for loop with package var and 4 integer list',
1088 setup => '$x = 1;',
1089 code => 'for $x (1,2,3,4) {}',
1090 },
1091 'loop::for::defsv_list4' => {
1092 desc => 'empty for loop with $_ and integer 4 list',
1093 setup => '',
1094 code => 'for (1,2,3,4) {}',
1095 },
1096
0724084c
DM
1097 'loop::for::my_array1' => {
1098 desc => 'empty for loop with my var and 1 integer array',
1099 setup => 'my @a = (1);',
1100 code => 'for my $x (@a) {}',
1101 },
1102 'loop::for::lex_array1' => {
1103 desc => 'empty for loop with lexical var and 1 integer array',
1104 setup => 'my $x; my @a = (1);',
1105 code => 'for $x (@a) {}',
1106 },
1107 'loop::for::pkg_array1' => {
1108 desc => 'empty for loop with package var and 1 integer array',
1109 setup => '$x = 1; my @a = (1);',
1110 code => 'for $x (@a) {}',
1111 },
1112 'loop::for::defsv_array1' => {
1113 desc => 'empty for loop with $_ and integer 1 array',
1114 setup => 'my @a = (@a);',
1115 code => 'for (1) {}',
1116 },
1117 'loop::for::my_array4' => {
1118 desc => 'empty for loop with my var and 4 integer array',
1119 setup => 'my @a = (1..4);',
1120 code => 'for my $x (@a) {}',
1121 },
1122 'loop::for::lex_array4' => {
1123 desc => 'empty for loop with lexical var and 4 integer array',
1124 setup => 'my $x; my @a = (1..4);',
1125 code => 'for $x (@a) {}',
1126 },
1127 'loop::for::pkg_array4' => {
1128 desc => 'empty for loop with package var and 4 integer array',
1129 setup => '$x = 1; my @a = (1..4);',
1130 code => 'for $x (@a) {}',
1131 },
1132 'loop::for::defsv_array4' => {
1133 desc => 'empty for loop with $_ and integer 4 array',
1134 setup => 'my @a = (1..4);',
1135 code => 'for (@a) {}',
1136 },
1137
cd97dc8d
DM
1138 'loop::for::next4' => {
1139 desc => 'for loop containing only next with my var and integer 4 array',
1140 setup => 'my @a = (1..4);',
1141 code => 'for my $x (@a) {next}',
1142 },
1143
56e049ca
DM
1144 'loop::grep::expr_3int' => {
1145 desc => 'grep $_ > 0, 1,2,3',
1146 setup => 'my @a',
1147 code => '@a = grep $_ > 0, 1,2,3',
1148 },
1149
1150 'loop::grep::block_3int' => {
1151 desc => 'grep { 1; $_ > 0} 1,2,3',
1152 setup => 'my @a',
1153 code => '@a = grep { 1; $_ > 0} 1,2,3',
1154 },
1155
1156 'loop::map::expr_3int' => {
1157 desc => 'map $_+1, 1,2,3',
1158 setup => 'my @a',
1159 code => '@a = map $_+1, 1,2,3',
1160 },
1161
1162 'loop::map::block_3int' => {
1163 desc => 'map { 1; $_+1} 1,2,3',
1164 setup => 'my @a',
1165 code => '@a = map { 1; $_+1} 1,2,3',
1166 },
1167
aedeb7c2
DM
1168 'loop::while::i1' => {
1169 desc => 'empty while loop 1 iteration',
1170 setup => 'my $i = 0;',
1171 code => 'while (++$i % 2) {}',
1172 },
1173 'loop::while::i4' => {
1174 desc => 'empty while loop 4 iterations',
1175 setup => 'my $i = 0;',
1176 code => 'while (++$i % 4) {}',
4c2c3128
DM
1177 },
1178
fedf30e1 1179];