This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Better optimise array and hash assignment
[perl5.git] / t / perf / benchmarks
1 #!perl
2
3 # This file specifies an array-of-hashes that define snippets of code that
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 #
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 #
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 #
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]
36 #     func::     perl functions, e.g. func::sort::...
37 #     loop::     structural code like for, while(), etc
38 #     regex::    regular expressions
39 #     string::   string handling
40 #
41 #
42 # Each hash has three fields:
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 }"
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
54
55
56 [
57     'call::sub::empty' => {
58         desc    => 'function call with no args or body',
59         setup   => 'sub f { }',
60         code    => 'f()',
61     },
62     'call::sub::amp_empty' => {
63         desc    => '&foo function call with no args or body',
64         setup   => 'sub f { }; @_ = ();',
65         code    => '&f',
66     },
67     'call::sub::args3' => {
68         desc    => 'function call with 3 local lexical vars',
69         setup   => 'sub f { my ($a, $b, $c) = @_; 1 }',
70         code    => 'f(1,2,3)',
71     },
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     },
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     },
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     },
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) = @_ }',
111         code    => 'f(1,2,3)',
112     },
113
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]]]',
148         code    => '($r||0)->[0][0][0]',
149     },
150
151
152     'expr::array::pkg_1const_0' => {
153         desc    => 'package $array[0]',
154         setup   => '@a = (1)',
155         code    => '$a[0]',
156     },
157     'expr::array::pkg_1const_m1' => {
158         desc    => 'package $array[-1]',
159         setup   => '@a = (1)',
160         code    => '$a[-1]',
161     },
162     'expr::array::pkg_2const' => {
163         desc    => 'package $array[const][const]',
164         setup   => '@a = ([1,2])',
165         code    => '$a[0][1]',
166     },
167     'expr::array::pkg_2var' => {
168         desc    => 'package $array[$i1][$i2]',
169         setup   => '($i1,$i2) = (0,1); @a = ([1,2])',
170         code    => '$a[$i1][$i2]',
171     },
172     'expr::array::ref_pkg_2var' => {
173         desc    => 'package $arrayref->[$i1][$i2]',
174         setup   => '($i1,$i2) = (0,1); $r = [[1,2]]',
175         code    => '$r->[$i1][$i2]',
176     },
177     'expr::array::ref_pkg_3const' => {
178         desc    => 'package $arrayref->[const][const][const]',
179         setup   => '$r = [[[1,2]]]',
180         code    => '$r->[0][0][0]',
181     },
182     'expr::array::ref_expr_pkg_3const' => {
183         desc    => '(package expr)->[const][const][const]',
184         setup   => '$r = [[[1,2]]]',
185         code    => '($r||0)->[0][0][0]',
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}',
197         setup   => '($i, $k1, $k2) = (0,"foo","bar");'
198                     . '%h = (foo => [ { bar => 1 } ])',
199         code    => '$h{$k1}[$i]{$k2}',
200     },
201
202
203     'expr::assign::scalar_lex_int' => {
204         desc    => 'lexical $x = 1',
205         setup   => 'my $x',
206         code    => '$x = 1',
207     },
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     },
223     'expr::assign::2list_lex' => {
224         desc    => 'lexical ($x, $y) = (1, 2)',
225         setup   => 'my ($x, $y)',
226         code    => '($x, $y) = (1, 2)',
227     },
228
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 }}}',
258         code    => '($r||0)->{foo}{bar}{baz}',
259     },
260
261
262     'expr::hash::pkg_1const' => {
263         desc    => 'package $hash{const}',
264         setup   => '%h = ("foo" => 1)',
265         code    => '$h{foo}',
266     },
267     'expr::hash::pkg_2const' => {
268         desc    => 'package $hash{const}{const}',
269         setup   => '%h = (foo => { bar => 1 })',
270         code    => '$h{foo}{bar}',
271     },
272     'expr::hash::pkg_2var' => {
273         desc    => 'package $hash{$k1}{$k2}',
274         setup   => '($k1,$k2) = qw(foo bar); %h = ($k1 => { $k2 => 1 })',
275         code    => '$h{$k1}{$k2}',
276     },
277     'expr::hash::ref_pkg_2var' => {
278         desc    => 'package $hashref->{$k1}{$k2}',
279         setup   => '($k1,$k2) = qw(foo bar); $r = {$k1 => { $k2 => 1 }}',
280         code    => '$r->{$k1}{$k2}',
281     },
282     'expr::hash::ref_pkg_3const' => {
283         desc    => 'package $hashref->{const}{const}{const}',
284         setup   => '$r = {foo => { bar => { baz => 1 }}}',
285         code    => '$r->{foo}{bar}{baz}',
286     },
287     'expr::hash::ref_expr_pkg_3const' => {
288         desc    => '(package expr)->{const}{const}{const}',
289         setup   => '$r = {foo => { bar => { baz => 1 }}}',
290         code    => '($r||0)->{foo}{bar}{baz}',
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
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     },
394     'expr::index::utf8_position_1' => {
395         desc    => 'index of a utf8 string, matching at position 1',
396         setup   => 'my $x = "abc". chr(0x100); chop $x',
397         code    => 'index $x, "b"',
398     },
399
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::mh_empty' => {
422         desc    => 'my hash assigned empty',
423         setup   => '',
424         code    => 'my %h = ()',
425     },
426     'expr::aassign::lhx_empty' => {
427         desc    => 'non-empty lexical hash assigned empty',
428         setup   => 'my %h = 1..4;',
429         code    => '%h = ()',
430     },
431     'expr::aassign::llhx_empty' => {
432         desc    => 'non-empty lexical var and hash assigned empty',
433         setup   => 'my ($x, %h) = 1..5;',
434         code    => '($x, %h) = ()',
435     },
436     'expr::aassign::3m_empty' => {
437         desc    => 'three my vars assigned empty',
438         setup   => '',
439         code    => 'my ($x,$y,$z) = ()',
440     },
441     'expr::aassign::3l_empty' => {
442         desc    => 'three lexical vars assigned empty',
443         setup   => 'my ($x,$y,$z)',
444         code    => '($x,$y,$z) = ()',
445     },
446     'expr::aassign::pa_empty' => {
447         desc    => 'package array assigned empty',
448         setup   => '',
449         code    => '@a = ()',
450     },
451     'expr::aassign::pax_empty' => {
452         desc    => 'non-empty package array assigned empty',
453         setup   => '@a = (1,2,3)',
454         code    => '@a = ()',
455     },
456     'expr::aassign::3p_empty' => {
457         desc    => 'three package vars assigned empty',
458         setup   => '($x,$y,$z) = 1..3;',
459         code    => '($x,$y,$z) = ()',
460     },
461
462     # (....) = (1,2,3)
463
464     'expr::aassign::ma_3c' => {
465         desc    => 'my array assigned 3 consts',
466         setup   => '',
467         code    => 'my @a = (1,2,3)',
468     },
469     'expr::aassign::lax_3c' => {
470         desc    => 'non-empty lexical array assigned 3 consts',
471         setup   => 'my @a = 1..3;',
472         code    => '@a = (1,2,3)',
473     },
474     'expr::aassign::llax_3c' => {
475         desc    => 'non-empty lexical var and array assigned 3 consts',
476         setup   => 'my ($x, @a) = 1..4;',
477         code    => '($x, @a) = (1,2,3)',
478     },
479     'expr::aassign::mh_4c' => {
480         desc    => 'my hash assigned 4 consts',
481         setup   => '',
482         code    => 'my %h = qw(a 1 b 2)',
483     },
484     'expr::aassign::lhx_4c' => {
485         desc    => 'non-empty lexical hash assigned 4 consts',
486         setup   => 'my %h = qw(a 1 b 2);',
487         code    => '%h = qw(c 3 d 4)',
488     },
489     'expr::aassign::llhx_5c' => {
490         desc    => 'non-empty lexical var and array assigned 5 consts',
491         setup   => 'my ($x, %h) = (1, qw(a 1 b 2));',
492         code    => '($x, %h) = (10, qw(c 3 d 4))',
493     },
494     'expr::aassign::3m_3c' => {
495         desc    => 'three my vars assigned 3 consts',
496         setup   => '',
497         code    => 'my ($x,$y,$z) = (1,2,3)',
498     },
499     'expr::aassign::3l_3c' => {
500         desc    => 'three lexical vars assigned 3 consts',
501         setup   => 'my ($x,$y,$z)',
502         code    => '($x,$y,$z) = (1,2,3)',
503     },
504     'expr::aassign::pa_3c' => {
505         desc    => 'package array assigned 3 consts',
506         setup   => '',
507         code    => '@a = (1,2,3)',
508     },
509     'expr::aassign::pax_3c' => {
510         desc    => 'non-empty package array assigned 3 consts',
511         setup   => '@a = (1,2,3)',
512         code    => '@a = (1,2,3)',
513     },
514     'expr::aassign::3p_3c' => {
515         desc    => 'three package vars assigned 3 consts',
516         setup   => '($x,$y,$z) = 1..3;',
517         code    => '($x,$y,$z) = (1,2,3)',
518     },
519
520     # (....) = @lexical
521
522     'expr::aassign::ma_la' => {
523         desc    => 'my array assigned lexical array',
524         setup   => 'my @init = 1..3;',
525         code    => 'my @a = @init',
526     },
527     'expr::aassign::lax_la' => {
528         desc    => 'non-empty lexical array assigned lexical array',
529         setup   => 'my @init = 1..3; my @a = 1..3;',
530         code    => '@a = @init',
531     },
532     'expr::aassign::llax_la' => {
533         desc    => 'non-empty lexical var and array assigned lexical array',
534         setup   => 'my @init = 1..3; my ($x, @a) = 1..4;',
535         code    => '($x, @a) = @init',
536     },
537     'expr::aassign::3m_la' => {
538         desc    => 'three my vars assigned lexical array',
539         setup   => 'my @init = 1..3;',
540         code    => 'my ($x,$y,$z) = @init',
541     },
542     'expr::aassign::3l_la' => {
543         desc    => 'three lexical vars assigned lexical array',
544         setup   => 'my @init = 1..3; my ($x,$y,$z)',
545         code    => '($x,$y,$z) = @init',
546     },
547     'expr::aassign::pa_la' => {
548         desc    => 'package array assigned lexical array',
549         setup   => 'my @init = 1..3;',
550         code    => '@a = @init',
551     },
552     'expr::aassign::pax_la' => {
553         desc    => 'non-empty package array assigned lexical array',
554         setup   => 'my @init = 1..3; @a = @init',
555         code    => '@a = @init',
556     },
557     'expr::aassign::3p_la' => {
558         desc    => 'three package vars assigned lexical array',
559         setup   => 'my @init = 1..3; ($x,$y,$z) = 1..3;',
560         code    => '($x,$y,$z) = @init',
561     },
562
563     # (....) = @package
564
565     'expr::aassign::ma_pa' => {
566         desc    => 'my array assigned package array',
567         setup   => '@init = 1..3;',
568         code    => 'my @a = @init',
569     },
570     'expr::aassign::lax_pa' => {
571         desc    => 'non-empty lexical array assigned package array',
572         setup   => '@init = 1..3; my @a = 1..3;',
573         code    => '@a = @init',
574     },
575     'expr::aassign::llax_pa' => {
576         desc    => 'non-empty lexical var and array assigned package array',
577         setup   => '@init = 1..3; my ($x, @a) = 1..4;',
578         code    => '($x, @a) = @init',
579     },
580     'expr::aassign::3m_pa' => {
581         desc    => 'three my vars assigned package array',
582         setup   => '@init = 1..3;',
583         code    => 'my ($x,$y,$z) = @init',
584     },
585     'expr::aassign::3l_pa' => {
586         desc    => 'three lexical vars assigned package array',
587         setup   => '@init = 1..3; my ($x,$y,$z)',
588         code    => '($x,$y,$z) = @init',
589     },
590     'expr::aassign::pa_pa' => {
591         desc    => 'package array assigned package array',
592         setup   => '@init = 1..3;',
593         code    => '@a = @init',
594     },
595     'expr::aassign::pax_pa' => {
596         desc    => 'non-empty package array assigned package array',
597         setup   => '@init = 1..3; @a = @init',
598         code    => '@a = @init',
599     },
600     'expr::aassign::3p_pa' => {
601         desc    => 'three package vars assigned package array',
602         setup   => '@init = 1..3; ($x,$y,$z) = 1..3;',
603         code    => '($x,$y,$z) = @init',
604     },
605
606     # (....) = @_;
607
608     'expr::aassign::ma_defary' => {
609         desc    => 'my array assigned @_',
610         setup   => '@_ = 1..3;',
611         code    => 'my @a = @_',
612     },
613     'expr::aassign::lax_defary' => {
614         desc    => 'non-empty lexical array assigned @_',
615         setup   => '@_ = 1..3; my @a = 1..3;',
616         code    => '@a = @_',
617     },
618     'expr::aassign::llax_defary' => {
619         desc    => 'non-empty lexical var and array assigned @_',
620         setup   => '@_ = 1..3; my ($x, @a) = 1..4;',
621         code    => '($x, @a) = @_',
622     },
623     'expr::aassign::3m_defary' => {
624         desc    => 'three my vars assigned @_',
625         setup   => '@_ = 1..3;',
626         code    => 'my ($x,$y,$z) = @_',
627     },
628     'expr::aassign::3l_defary' => {
629         desc    => 'three lexical vars assigned @_',
630         setup   => '@_ = 1..3; my ($x,$y,$z)',
631         code    => '($x,$y,$z) = @_',
632     },
633     'expr::aassign::pa_defary' => {
634         desc    => 'package array assigned @_',
635         setup   => '@_ = 1..3;',
636         code    => '@a = @_',
637     },
638     'expr::aassign::pax_defary' => {
639         desc    => 'non-empty package array assigned @_',
640         setup   => '@_ = 1..3; @a = @_',
641         code    => '@a = @_',
642     },
643     'expr::aassign::3p_defary' => {
644         desc    => 'three package vars assigned @_',
645         setup   => '@_ = 1..3; ($x,$y,$z) = 1..3;',
646         code    => '($x,$y,$z) = @_',
647     },
648
649
650     # (....) = ($lex1,$lex2,$lex3);
651
652     'expr::aassign::ma_3l' => {
653         desc    => 'my array assigned lexicals',
654         setup   => 'my ($v1,$v2,$v3) = 1..3;',
655         code    => 'my @a = ($v1,$v2,$v3)',
656     },
657     'expr::aassign::lax_3l' => {
658         desc    => 'non-empty lexical array assigned lexicals',
659         setup   => 'my ($v1,$v2,$v3) = 1..3; my @a = 1..3;',
660         code    => '@a = ($v1,$v2,$v3)',
661     },
662     'expr::aassign::llax_3l' => {
663         desc    => 'non-empty lexical var and array assigned lexicals',
664         setup   => 'my ($v1,$v2,$v3) = 1..3; my ($x, @a) = 1..4;',
665         code    => '($x, @a) = ($v1,$v2,$v3)',
666     },
667     'expr::aassign::3m_3l' => {
668         desc    => 'three my vars assigned lexicals',
669         setup   => 'my ($v1,$v2,$v3) = 1..3;',
670         code    => 'my ($x,$y,$z) = ($v1,$v2,$v3)',
671     },
672     'expr::aassign::3l_3l' => {
673         desc    => 'three lexical vars assigned lexicals',
674         setup   => 'my ($v1,$v2,$v3) = 1..3; my ($x,$y,$z)',
675         code    => '($x,$y,$z) = ($v1,$v2,$v3)',
676     },
677     'expr::aassign::pa_3l' => {
678         desc    => 'package array assigned lexicals',
679         setup   => 'my ($v1,$v2,$v3) = 1..3;',
680         code    => '@a = ($v1,$v2,$v3)',
681     },
682     'expr::aassign::pax_3l' => {
683         desc    => 'non-empty package array assigned lexicals',
684         setup   => 'my ($v1,$v2,$v3) = 1..3; @a = @_',
685         code    => '@a = ($v1,$v2,$v3)',
686     },
687     'expr::aassign::3p_3l' => {
688         desc    => 'three package vars assigned lexicals',
689         setup   => 'my ($v1,$v2,$v3) = 1..3; ($x,$y,$z) = 1..3;',
690         code    => '($x,$y,$z) = ($v1,$v2,$v3)',
691     },
692
693
694     # (....) = ($pkg1,$pkg2,$pkg3);
695
696     'expr::aassign::ma_3p' => {
697         desc    => 'my array assigned 3 package vars',
698         setup   => '($v1,$v2,$v3) = 1..3;',
699         code    => 'my @a = ($v1,$v2,$v3)',
700     },
701     'expr::aassign::lax_3p' => {
702         desc    => 'non-empty lexical array assigned 3 package vars',
703         setup   => '($v1,$v2,$v3) = 1..3; my @a = 1..3;',
704         code    => '@a = ($v1,$v2,$v3)',
705     },
706     'expr::aassign::llax_3p' => {
707         desc    => 'non-empty lexical var and array assigned 3 package vars',
708         setup   => '($v1,$v2,$v3) = 1..3; my ($x, @a) = 1..4;',
709         code    => '($x, @a) = ($v1,$v2,$v3)',
710     },
711     'expr::aassign::3m_3p' => {
712         desc    => 'three my vars assigned 3 package vars',
713         setup   => '($v1,$v2,$v3) = 1..3;',
714         code    => 'my ($x,$y,$z) = ($v1,$v2,$v3)',
715     },
716     'expr::aassign::3l_3p' => {
717         desc    => 'three lexical vars assigned 3 package vars',
718         setup   => '($v1,$v2,$v3) = 1..3; my ($x,$y,$z)',
719         code    => '($x,$y,$z) = ($v1,$v2,$v3)',
720     },
721     'expr::aassign::pa_3p' => {
722         desc    => 'package array assigned 3 package vars',
723         setup   => '($v1,$v2,$v3) = 1..3;',
724         code    => '@a = ($v1,$v2,$v3)',
725     },
726     'expr::aassign::pax_3p' => {
727         desc    => 'non-empty package array assigned 3 package vars',
728         setup   => '($v1,$v2,$v3) = 1..3; @a = @_',
729         code    => '@a = ($v1,$v2,$v3)',
730     },
731     'expr::aassign::3p_3p' => {
732         desc    => 'three package vars assigned 3 package vars',
733         setup   => '($v1,$v2,$v3) = 1..3; ($x,$y,$z) = 1..3;',
734         code    => '($x,$y,$z) = ($v1,$v2,$v3)',
735     },
736
737
738     # (....) = (1,2,$shared);
739
740     'expr::aassign::llax_2c1s' => {
741         desc    => 'non-empty lexical var and array assigned 2 consts and 1 shared var',
742         setup   => 'my ($x, @a) = 1..4;',
743         code    => '($x, @a) = (1,2,$x)',
744     },
745     'expr::aassign::3l_2c1s' => {
746         desc    => 'three lexical vars assigned 2 consts and 1 shared var',
747         setup   => 'my ($x,$y,$z) = 1..3;',
748         code    => '($x,$y,$z) = (1,2,$x)',
749     },
750     'expr::aassign::3p_2c1s' => {
751         desc    => 'three package vars assigned 2 consts and 1 shared var',
752         setup   => '($x,$y,$z) = 1..3;',
753         code    => '($x,$y,$z) = (1,2,$x)',
754     },
755
756
757     # ($a,$b) = ($b,$a);
758
759     'expr::aassign::2l_swap' => {
760         desc    => 'swap two lexical vars',
761         setup   => 'my ($a,$b) = (1,2)',
762         code    => '($a,$b) = ($b,$a)',
763     },
764     'expr::aassign::2p_swap' => {
765         desc    => 'swap two package vars',
766         setup   => '($a,$b) = (1,2)',
767         code    => '($a,$b) = ($b,$a)',
768     },
769     'expr::aassign::2laelem_swap' => {
770         desc    => 'swap two lexical vars',
771         setup   => 'my @a = (1,2)',
772         code    => '($a[0],$a[1]) = ($a[1],$a[0])',
773     },
774
775     # misc list assign
776
777     'expr::aassign::5l_4l1s' => {
778         desc    => 'long list of lexical vars, 1 shared',
779         setup   => 'my ($a,$b,$c,$d,$e) = 1..5',
780         code    => '($a,$b,$c,$d,$e) = ($a,$a,$c,$d,$e)',
781     },
782
783     'expr::aassign::5p_4p1s' => {
784         desc    => 'long list of package vars, 1 shared',
785         setup   => '($a,$b,$c,$d,$e) = 1..5',
786         code    => '($a,$b,$c,$d,$e) = ($a,$a,$c,$d,$e)',
787     },
788     'expr::aassign::5l_defary' => {
789         desc    => 'long list of lexical vars to assign @_ to',
790         setup   => '@_ = 1..5',
791         code    => 'my ($a,$b,$c,$d,$e) = @_',
792     },
793     'expr::aassign::5l1la_defary' => {
794         desc    => 'long list of lexical vars plus long slurp to assign @_ to',
795         setup   => '@_ = 1..20',
796         code    => 'my ($a,$b,$c,$d,$e,@rest) = @_',
797     },
798     'expr::aassign::1l_2l' => {
799         desc    => 'single lexical LHS',
800         setup   => 'my $x = 1;',
801         code    => '(undef,$x) = ($x,$x)',
802     },
803     'expr::aassign::2l_1l' => {
804         desc    => 'single lexical RHS',
805         setup   => 'my $x = 1;',
806         code    => '($x,$x) = ($x)',
807     },
808     'expr::aassign::2l_1ul' => {
809         desc    => 'undef and single lexical RHS',
810         setup   => 'my $x = 1;',
811         code    => '($x,$x) = (undef, $x)',
812     },
813
814     # array assign of strings
815
816     'expr::aassign::la_3s' => {
817         desc    => 'assign 3 strings to empty lexical array',
818         setup   => 'my @a',
819         code    => '@a = (); @a = qw(abc defg hijkl);',
820     },
821     'expr::aassign::la_3ts' => {
822         desc    => 'assign 3 temp strings to empty lexical array',
823         setup   => 'my @a',
824         code    => '@a = (); @a = map $_, qw(abc defg hijkl);',
825     },
826     'expr::aassign::lan_3s' => {
827         desc    => 'assign 3 strings to non-empty lexical array',
828         setup   => 'my @a = qw(abc defg hijkl)',
829         code    => '@a = qw(abc defg hijkl);',
830     },
831     'expr::aassign::lan_3ts' => {
832         desc    => 'assign 3 temp strings to non-empty lexical array',
833         setup   => 'my @a = qw(abc defg hijkl)',
834         code    => '@a = map $_, qw(abc defg hijkl);',
835     },
836
837     # hash assign of strings
838
839     'expr::aassign::lh_2s' => {
840         desc    => 'assign 2 strings to empty lexical hash',
841         setup   => 'my %h',
842         code    => '%h = (); %h = qw(k1 abc k2 defg);',
843     },
844     'expr::aassign::lh_2ts' => {
845         desc    => 'assign 2 temp strings to empty lexical hash',
846         setup   => 'my %h',
847         code    => '%h = (); %h = map $_, qw(k1 abc k2 defg);',
848     },
849     'expr::aassign::lhn_2s' => {
850         desc    => 'assign 2 strings to non-empty lexical hash',
851         setup   => 'my %h = qw(k1 abc k2 defg);',
852         code    => '%h = qw(k1 abc k2 defg);',
853     },
854     'expr::aassign::lhn_2ts' => {
855         desc    => 'assign 2 temp strings to non-empty lexical hash',
856         setup   => 'my %h = qw(k1 abc k2 defg);',
857         code    => '%h = map $_, qw(k1 abc k2 defg);',
858     },
859
860
861     'expr::arith::add_lex_ii' => {
862         desc    => 'add two integers and assign to a lexical var',
863         setup   => 'my ($x,$y,$z) = 1..3;',
864         code    => '$z = $x + $y',
865     },
866     'expr::arith::add_pkg_ii' => {
867         desc    => 'add two integers and assign to a package var',
868         setup   => 'my ($x,$y) = 1..2; $z = 3;',
869         code    => '$z = $x + $y',
870     },
871     'expr::arith::add_lex_nn' => {
872         desc    => 'add two NVs and assign to a lexical var',
873         setup   => 'my ($x,$y,$z) = (1.1, 2.2, 3.3);',
874         code    => '$z = $x + $y',
875     },
876     'expr::arith::add_pkg_nn' => {
877         desc    => 'add two NVs and assign to a package var',
878         setup   => 'my ($x,$y); ($x,$y,$z) = (1.1, 2.2, 3.3);',
879         code    => '$z = $x + $y',
880     },
881     'expr::arith::add_lex_ni' => {
882         desc    => 'add an int and an NV and assign to a lexical var',
883         setup   => 'my ($x,$y,$z) = (1, 2.2, 3.3);',
884         code    => '$z = $x + $y',
885     },
886     'expr::arith::add_pkg_ni' => {
887         desc    => 'add an int and an NV and assign to a package var',
888         setup   => 'my ($x,$y); ($x,$y,$z) = (1, 2.2, 3.3);',
889         code    => '$z = $x + $y',
890     },
891     'expr::arith::add_lex_ss' => {
892         desc    => 'add two short strings and assign to a lexical var',
893         setup   => 'my ($x,$y,$z) = ("1", "2", 1);',
894         code    => '$z = $x + $y; $x = "1"; ',
895     },
896
897     'expr::arith::add_lex_ll' => {
898         desc    => 'add two long strings and assign to a lexical var',
899         setup   => 'my ($x,$y,$z) = ("12345", "23456", 1);',
900         code    => '$z = $x + $y; $x = "12345"; ',
901     },
902
903     'expr::arith::sub_lex_ii' => {
904         desc    => 'subtract two integers and assign to a lexical var',
905         setup   => 'my ($x,$y,$z) = 1..3;',
906         code    => '$z = $x - $y',
907     },
908     'expr::arith::sub_pkg_ii' => {
909         desc    => 'subtract two integers and assign to a package var',
910         setup   => 'my ($x,$y) = 1..2; $z = 3;',
911         code    => '$z = $x - $y',
912     },
913     'expr::arith::sub_lex_nn' => {
914         desc    => 'subtract two NVs and assign to a lexical var',
915         setup   => 'my ($x,$y,$z) = (1.1, 2.2, 3.3);',
916         code    => '$z = $x - $y',
917     },
918     'expr::arith::sub_pkg_nn' => {
919         desc    => 'subtract two NVs and assign to a package var',
920         setup   => 'my ($x,$y); ($x,$y,$z) = (1.1, 2.2, 3.3);',
921         code    => '$z = $x - $y',
922     },
923     'expr::arith::sub_lex_ni' => {
924         desc    => 'subtract an int and an NV and assign to a lexical var',
925         setup   => 'my ($x,$y,$z) = (1, 2.2, 3.3);',
926         code    => '$z = $x - $y',
927     },
928     'expr::arith::sub_pkg_ni' => {
929         desc    => 'subtract an int and an NV and assign to a package var',
930         setup   => 'my ($x,$y); ($x,$y,$z) = (1, 2.2, 3.3);',
931         code    => '$z = $x - $y',
932     },
933
934     'expr::arith::mult_lex_ii' => {
935         desc    => 'multiply two integers and assign to a lexical var',
936         setup   => 'my ($x,$y,$z) = 1..3;',
937         code    => '$z = $x * $y',
938     },
939     'expr::arith::mult_pkg_ii' => {
940         desc    => 'multiply two integers and assign to a package var',
941         setup   => 'my ($x,$y) = 1..2; $z = 3;',
942         code    => '$z = $x * $y',
943     },
944     'expr::arith::mult_lex_nn' => {
945         desc    => 'multiply two NVs and assign to a lexical var',
946         setup   => 'my ($x,$y,$z) = (1.1, 2.2, 3.3);',
947         code    => '$z = $x * $y',
948     },
949     'expr::arith::mult_pkg_nn' => {
950         desc    => 'multiply two NVs and assign to a package var',
951         setup   => 'my ($x,$y); ($x,$y,$z) = (1.1, 2.2, 3.3);',
952         code    => '$z = $x * $y',
953     },
954     'expr::arith::mult_lex_ni' => {
955         desc    => 'multiply an int and an NV and assign to a lexical var',
956         setup   => 'my ($x,$y,$z) = (1, 2.2, 3.3);',
957         code    => '$z = $x * $y',
958     },
959     'expr::arith::mult_pkg_ni' => {
960         desc    => 'multiply an int and an NV and assign to a package var',
961         setup   => 'my ($x,$y); ($x,$y,$z) = (1, 2.2, 3.3);',
962         code    => '$z = $x * $y',
963     },
964
965     'expr::arith::preinc' => {
966         desc    => '++$x',
967         setup   => 'my $x = 1;',
968         code    => '++$x',
969     },
970     'expr::arith::predec' => {
971         desc    => '--$x',
972         setup   => 'my $x = 1;',
973         code    => '--$x',
974     },
975     'expr::arith::postinc' => {
976         desc    => '$x++',
977         setup   => 'my $x = 1; my $y',
978         code    => '$y = $x++', # scalar context so not optimised to ++$x
979     },
980     'expr::arith::postdec' => {
981         desc    => '$x--',
982         setup   => 'my $x = 1; my $y',
983         code    => '$y = $x--', # scalar context so not optimised to --$x
984     },
985
986
987
988     'func::sort::num' => {
989         desc    => 'plain numeric sort',
990         setup   => 'my (@a, @b); @a = reverse 1..10;',
991         code    => '@b = sort { $a <=> $b } @a',
992     },
993     'func::sort::num_block' => {
994         desc    => 'codeblock numeric sort',
995         setup   => 'my (@a, @b); @a = reverse 1..10;',
996         code    => '@b = sort { $a + 1 <=> $b + 1 } @a',
997     },
998     'func::sort::num_fn' => {
999         desc    => 'function numeric sort',
1000         setup   => 'sub f { $a + 1 <=> $b + 1 } my (@a, @b); @a = reverse 1..10;',
1001         code    => '@b = sort f @a',
1002     },
1003     'func::sort::str' => {
1004         desc    => 'plain string sort',
1005         setup   => 'my (@a, @b); @a = reverse "a".."j";',
1006         code    => '@b = sort { $a cmp $b } @a',
1007     },
1008     'func::sort::str_block' => {
1009         desc    => 'codeblock string sort',
1010         setup   => 'my (@a, @b); @a = reverse "a".."j";',
1011         code    => '@b = sort { ($a . "") cmp ($b . "") } @a',
1012     },
1013     'func::sort::str_fn' => {
1014         desc    => 'function string sort',
1015         setup   => 'sub f { ($a . "") cmp ($b . "") } my (@a, @b); @a = reverse  "a".."j";',
1016         code    => '@b = sort f @a',
1017     },
1018
1019     'func::sort::num_inplace' => {
1020         desc    => 'plain numeric sort in-place',
1021         setup   => 'my @a = reverse 1..10;',
1022         code    => '@a = sort { $a <=> $b } @a',
1023     },
1024     'func::sort::num_block_inplace' => {
1025         desc    => 'codeblock numeric sort in-place',
1026         setup   => 'my @a = reverse 1..10;',
1027         code    => '@a = sort { $a + 1 <=> $b + 1 } @a',
1028     },
1029     'func::sort::num_fn_inplace' => {
1030         desc    => 'function numeric sort in-place',
1031         setup   => 'sub f { $a + 1 <=> $b + 1 } my @a = reverse 1..10;',
1032         code    => '@a = sort f @a',
1033     },
1034     'func::sort::str_inplace' => {
1035         desc    => 'plain string sort in-place',
1036         setup   => 'my @a = reverse "a".."j";',
1037         code    => '@a = sort { $a cmp $b } @a',
1038     },
1039     'func::sort::str_block_inplace' => {
1040         desc    => 'codeblock string sort in-place',
1041         setup   => 'my @a = reverse "a".."j";',
1042         code    => '@a = sort { ($a . "") cmp ($b . "") } @a',
1043     },
1044     'func::sort::str_fn_inplace' => {
1045         desc    => 'function string sort in-place',
1046         setup   => 'sub f { ($a . "") cmp ($b . "") } my @a = reverse  "a".."j";',
1047         code    => '@a = sort f @a',
1048     },
1049
1050
1051     'func::split::vars' => {
1052         desc    => 'split into two lexical vars',
1053         setup   => 'my $s = "abc:def";',
1054         code    => 'my ($x, $y) = split /:/, $s, 2;',
1055     },
1056
1057     'func::split::array' => {
1058         desc    => 'split into a lexical array',
1059         setup   => 'my @a; my $s = "abc:def";',
1060         code    => '@a = split /:/, $s, 2;',
1061     },
1062     'func::split::myarray' => {
1063         desc    => 'split into a lexical array declared in the assign',
1064         setup   => 'my $s = "abc:def";',
1065         code    => 'my @a = split /:/, $s, 2;',
1066     },
1067     'func::split::arrayexpr' => {
1068         desc    => 'split into an @{$expr} ',
1069         setup   => 'my $s = "abc:def"; my $r = []',
1070         code    => '@$r = split /:/, $s, 2;',
1071     },
1072     'func::split::arraylist' => {
1073         desc    => 'split into an array with extra arg',
1074         setup   => 'my @a; my $s = "abc:def";',
1075         code    => '@a = (split(/:/, $s, 2), 1);',
1076     },
1077
1078
1079     'loop::block' => {
1080         desc    => 'empty basic loop',
1081         setup   => '',
1082         code    => '{1;}',
1083     },
1084
1085     'loop::do' => {
1086         desc    => 'basic do block',
1087         setup   => 'my $x; my $y = 2;',
1088         code    => '$x = do {1; $y}', # the ';' stops the do being optimised
1089     },
1090
1091     'loop::for::my_range1' => {
1092         desc    => 'empty for loop with my var and 1 integer range',
1093         setup   => '',
1094         code    => 'for my $x (1..1) {}',
1095     },
1096     'loop::for::lex_range1' => {
1097         desc    => 'empty for loop with lexical var and 1 integer range',
1098         setup   => 'my $x;',
1099         code    => 'for $x (1..1) {}',
1100     },
1101     'loop::for::pkg_range1' => {
1102         desc    => 'empty for loop with package var and 1 integer range',
1103         setup   => '$x = 1;',
1104         code    => 'for $x (1..1) {}',
1105     },
1106     'loop::for::defsv_range1' => {
1107         desc    => 'empty for loop with $_ and integer 1 range',
1108         setup   => ';',
1109         code    => 'for (1..1) {}',
1110     },
1111     'loop::for::my_range4' => {
1112         desc    => 'empty for loop with my var and 4 integer range',
1113         setup   => '',
1114         code    => 'for my $x (1..4) {}',
1115     },
1116     'loop::for::lex_range4' => {
1117         desc    => 'empty for loop with lexical var and 4 integer range',
1118         setup   => 'my $x;',
1119         code    => 'for $x (1..4) {}',
1120     },
1121     'loop::for::pkg_range4' => {
1122         desc    => 'empty for loop with package var and 4 integer range',
1123         setup   => '$x = 1;',
1124         code    => 'for $x (1..4) {}',
1125     },
1126     'loop::for::defsv_range4' => {
1127         desc    => 'empty for loop with $_ and integer 4 range',
1128         setup   => ';',
1129         code    => 'for (1..4) {}',
1130     },
1131
1132     'loop::for::my_list1' => {
1133         desc    => 'empty for loop with my var and 1 integer list',
1134         setup   => '',
1135         code    => 'for my $x (1) {}',
1136     },
1137     'loop::for::lex_list1' => {
1138         desc    => 'empty for loop with lexical var and 1 integer list',
1139         setup   => 'my $x;',
1140         code    => 'for $x (1) {}',
1141     },
1142     'loop::for::pkg_list1' => {
1143         desc    => 'empty for loop with package var and 1 integer list',
1144         setup   => '$x = 1;',
1145         code    => 'for $x (1) {}',
1146     },
1147     'loop::for::defsv_list1' => {
1148         desc    => 'empty for loop with $_ and integer 1 list',
1149         setup   => ';',
1150         code    => 'for (1) {}',
1151     },
1152     'loop::for::my_list4' => {
1153         desc    => 'empty for loop with my var and 4 integer list',
1154         setup   => '',
1155         code    => 'for my $x (1,2,3,4) {}',
1156     },
1157     'loop::for::lex_list4' => {
1158         desc    => 'empty for loop with lexical var and 4 integer list',
1159         setup   => 'my $x;',
1160         code    => 'for $x (1,2,3,4) {}',
1161     },
1162     'loop::for::pkg_list4' => {
1163         desc    => 'empty for loop with package var and 4 integer list',
1164         setup   => '$x = 1;',
1165         code    => 'for $x (1,2,3,4) {}',
1166     },
1167     'loop::for::defsv_list4' => {
1168         desc    => 'empty for loop with $_ and integer 4 list',
1169         setup   => '',
1170         code    => 'for (1,2,3,4) {}',
1171     },
1172
1173     'loop::for::my_array1' => {
1174         desc    => 'empty for loop with my var and 1 integer array',
1175         setup   => 'my @a = (1);',
1176         code    => 'for my $x (@a) {}',
1177     },
1178     'loop::for::lex_array1' => {
1179         desc    => 'empty for loop with lexical var and 1 integer array',
1180         setup   => 'my $x; my @a = (1);',
1181         code    => 'for $x (@a) {}',
1182     },
1183     'loop::for::pkg_array1' => {
1184         desc    => 'empty for loop with package var and 1 integer array',
1185         setup   => '$x = 1; my @a = (1);',
1186         code    => 'for $x (@a) {}',
1187     },
1188     'loop::for::defsv_array1' => {
1189         desc    => 'empty for loop with $_ and integer 1 array',
1190         setup   => 'my @a = (@a);',
1191         code    => 'for (1) {}',
1192     },
1193     'loop::for::my_array4' => {
1194         desc    => 'empty for loop with my var and 4 integer array',
1195         setup   => 'my @a = (1..4);',
1196         code    => 'for my $x (@a) {}',
1197     },
1198     'loop::for::lex_array4' => {
1199         desc    => 'empty for loop with lexical var and 4 integer array',
1200         setup   => 'my $x; my @a = (1..4);',
1201         code    => 'for $x (@a) {}',
1202     },
1203     'loop::for::pkg_array4' => {
1204         desc    => 'empty for loop with package var and 4 integer array',
1205         setup   => '$x = 1; my @a = (1..4);',
1206         code    => 'for $x (@a) {}',
1207     },
1208     'loop::for::defsv_array4' => {
1209         desc    => 'empty for loop with $_ and integer 4 array',
1210         setup   => 'my @a = (1..4);',
1211         code    => 'for (@a) {}',
1212     },
1213
1214     'loop::for::next4' => {
1215         desc    => 'for loop containing only next with my var and integer 4 array',
1216         setup   => 'my @a = (1..4);',
1217         code    => 'for my $x (@a) {next}',
1218     },
1219
1220     'loop::grep::expr_3int' => {
1221         desc    => 'grep $_ > 0, 1,2,3',
1222         setup   => 'my @a',
1223         code    => '@a = grep $_ > 0, 1,2,3',
1224     },
1225
1226     'loop::grep::block_3int' => {
1227         desc    => 'grep { 1; $_ > 0} 1,2,3',
1228         setup   => 'my @a',
1229         code    => '@a = grep { 1; $_ > 0} 1,2,3',
1230     },
1231
1232     'loop::map::expr_3int' => {
1233         desc    => 'map $_+1, 1,2,3',
1234         setup   => 'my @a',
1235         code    => '@a = map $_+1, 1,2,3',
1236     },
1237
1238     'loop::map::block_3int' => {
1239         desc    => 'map { 1; $_+1} 1,2,3',
1240         setup   => 'my @a',
1241         code    => '@a = map { 1; $_+1} 1,2,3',
1242     },
1243
1244     'loop::while::i1' => {
1245         desc    => 'empty while loop 1 iteration',
1246         setup   => 'my $i = 0;',
1247         code    => 'while (++$i % 2) {}',
1248     },
1249     'loop::while::i4' => {
1250         desc    => 'empty while loop 4 iterations',
1251         setup   => 'my $i = 0;',
1252         code    => 'while (++$i % 4) {}',
1253     },
1254
1255 ];