This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
UnTODO some tests fixed by the previous commit
[perl5.git] / lib / B / Deparse.t
1 #!./perl
2
3 BEGIN {
4     splice @INC, 0, 0, 't', '.';
5     require Config;
6     if (($Config::Config{'extensions'} !~ /\bB\b/) ){
7         print "1..0 # Skip -- Perl configured without B module\n";
8         exit 0;
9     }
10     require 'test.pl';
11 }
12
13 use warnings;
14 use strict;
15
16 my $tests = 52; # not counting those in the __DATA__ section
17
18 use B::Deparse;
19 my $deparse = B::Deparse->new();
20 isa_ok($deparse, 'B::Deparse', 'instantiate a B::Deparse object');
21 my %deparse;
22
23 $/ = "\n####\n";
24 while (<DATA>) {
25     chomp;
26     $tests ++;
27     # This code is pinched from the t/lib/common.pl for TODO.
28     # It's not clear how to avoid duplication
29     my %meta = (context => '');
30     foreach my $what (qw(skip todo context options)) {
31         s/^#\s*\U$what\E\s*(.*)\n//m and $meta{$what} = $1;
32         # If the SKIP reason starts ? then it's taken as a code snippet to
33         # evaluate. This provides the flexibility to have conditional SKIPs
34         if ($meta{$what} && $meta{$what} =~ s/^\?//) {
35             my $temp = eval $meta{$what};
36             if ($@) {
37                 die "# In \U$what\E code reason:\n# $meta{$what}\n$@";
38             }
39             $meta{$what} = $temp;
40         }
41     }
42
43     s/^\s*#\s*(.*)$//mg;
44     my $desc = $1;
45     die "Missing name in test $_" unless defined $desc;
46
47     if ($meta{skip}) {
48         SKIP: { skip($meta{skip}) };
49         next;
50     }
51
52     my ($input, $expected);
53     if (/(.*)\n>>>>\n(.*)/s) {
54         ($input, $expected) = ($1, $2);
55     }
56     else {
57         ($input, $expected) = ($_, $_);
58     }
59
60     # parse options if necessary
61     my $deparse = $meta{options}
62         ? $deparse{$meta{options}} ||=
63             new B::Deparse split /,/, $meta{options}
64         : $deparse;
65
66     my $code = "$meta{context};\n" . <<'EOC' . "sub {$input\n}";
67 # Tell B::Deparse about our ambient pragmas
68 my ($hint_bits, $warning_bits, $hinthash);
69 BEGIN {
70     ($hint_bits, $warning_bits, $hinthash) = ($^H, ${^WARNING_BITS}, \%^H);
71 }
72 $deparse->ambient_pragmas (
73     hint_bits    => $hint_bits,
74     warning_bits => $warning_bits,
75     '%^H'        => $hinthash,
76 );
77 EOC
78     my $coderef = eval $code;
79
80     local $::TODO = $meta{todo};
81     if ($@) {
82         is($@, "", "compilation of $desc")
83             or diag "=============================================\n"
84                   . "CODE:\n--------\n$code\n--------\n"
85                   . "=============================================\n";
86     }
87     else {
88         my $deparsed = $deparse->coderef2text( $coderef );
89         my $regex = $expected;
90         $regex =~ s/(\S+)/\Q$1/g;
91         $regex =~ s/\s+/\\s+/g;
92         $regex = '^\{\s*' . $regex . '\s*\}$';
93
94         like($deparsed, qr/$regex/, $desc)
95             or diag "=============================================\n"
96                   . "CODE:\n--------\n$input\n--------\n"
97                   . "EXPECTED:\n--------\n{\n$expected\n}\n--------\n"
98                   . "GOT:\n--------\n$deparsed\n--------\n"
99                   . "=============================================\n";
100     }
101 }
102
103 # Reset the ambient pragmas
104 {
105     my ($b, $w, $h);
106     BEGIN {
107         ($b, $w, $h) = ($^H, ${^WARNING_BITS}, \%^H);
108     }
109     $deparse->ambient_pragmas (
110         hint_bits    => $b,
111         warning_bits => $w,
112         '%^H'        => $h,
113     );
114 }
115
116 use constant 'c', 'stuff';
117 is((eval "sub ".$deparse->coderef2text(\&c))->(), 'stuff',
118    'the subroutine generated by use constant deparses');
119
120 my $a = 0;
121 is($deparse->coderef2text(sub{(-1) ** $a }), "{\n    (-1) ** \$a;\n}",
122    'anon sub capturing an external lexical');
123
124 use constant cr => ['hello'];
125 my $string = "sub " . $deparse->coderef2text(\&cr);
126 my $val = (eval $string)->() or diag $string;
127 is(ref($val), 'ARRAY', 'constant array references deparse');
128 is($val->[0], 'hello', 'and return the correct value');
129
130 my $path = join " ", map { qq["-I$_"] } @INC;
131
132 $a = `$^X $path "-MO=Deparse" -anlwi.bak -e 1 2>&1`;
133 $a =~ s/-e syntax OK\n//g;
134 $a =~ s/.*possible typo.*\n//;     # Remove warning line
135 $a =~ s/.*-i used with no filenames.*\n//;      # Remove warning line
136 $b = quotemeta <<'EOF';
137 BEGIN { $^I = ".bak"; }
138 BEGIN { $^W = 1; }
139 BEGIN { $/ = "\n"; $\ = "\n"; }
140 LINE: while (defined($_ = readline ARGV)) {
141     chomp $_;
142     our(@F) = split(' ', $_, 0);
143     '???';
144 }
145 EOF
146 $b =~ s/our\\\(\\\@F\\\)/our[( ]\@F\\)?/; # accept both our @F and our(@F)
147 like($a, qr/$b/,
148    'command line flags deparse as BEGIN blocks setting control variables');
149
150 $a = `$^X $path "-MO=Deparse" -e "use constant PI => 4" 2>&1`;
151 $a =~ s/-e syntax OK\n//g;
152 is($a, "use constant ('PI', 4);\n",
153    "Proxy Constant Subroutines must not show up as (incorrect) prototypes");
154
155 $a = `$^X $path "-MO=Deparse" -e "sub foo(){1}" 2>&1`;
156 $a =~ s/-e syntax OK\n//g;
157 is($a, "sub foo () {\n    1;\n}\n",
158    "Main prog consisting of just a constant (via empty proto)");
159
160 $a = readpipe qq|$^X $path "-MO=Deparse"|
161              .qq| -e "package F; sub f(){0} sub s{}"|
162              .qq| -e "#line 123 four-five-six"|
163              .qq| -e "package G; sub g(){0} sub s{}" 2>&1|;
164 $a =~ s/-e syntax OK\n//g;
165 like($a, qr/sub F::f \(\) \{\s*0;?\s*}/,
166    "Constant is dumped in package in which other subs are dumped");
167 unlike($a, qr/sub g/,
168    "Constant is not dumped in package in which other subs are not dumped");
169
170 #Re: perlbug #35857, patch #24505
171 #handle warnings::register-ed packages properly.
172 package B::Deparse::Wrapper;
173 use strict;
174 use warnings;
175 use warnings::register;
176 sub getcode {
177    my $deparser = B::Deparse->new();
178    return $deparser->coderef2text(shift);
179 }
180
181 package Moo;
182 use overload '0+' => sub { 42 };
183
184 package main;
185 use strict;
186 use warnings;
187 use constant GLIPP => 'glipp';
188 use constant PI => 4;
189 use constant OVERLOADED_NUMIFICATION => bless({}, 'Moo');
190 use Fcntl qw/O_TRUNC O_APPEND O_EXCL/;
191 BEGIN { delete $::Fcntl::{O_APPEND}; }
192 use POSIX qw/O_CREAT/;
193 sub test {
194    my $val = shift;
195    my $res = B::Deparse::Wrapper::getcode($val);
196    like($res, qr/use warnings/,
197         '[perl #35857] [PATCH] B::Deparse doesnt handle warnings register properly');
198 }
199 my ($q,$p);
200 my $x=sub { ++$q,++$p };
201 test($x);
202 eval <<EOFCODE and test($x);
203    package bar;
204    use strict;
205    use warnings;
206    use warnings::register;
207    package main;
208    1
209 EOFCODE
210
211 # Exotic sub declarations
212 $a = `$^X $path "-MO=Deparse" -e "sub ::::{}sub ::::::{}" 2>&1`;
213 $a =~ s/-e syntax OK\n//g;
214 is($a, <<'EOCODG', "sub :::: and sub ::::::");
215 sub :::: {
216     
217 }
218 sub :::::: {
219     
220 }
221 EOCODG
222
223 # [perl #117311]
224 $a = `$^X $path "-MO=Deparse,-l" -e "map{ eval(0) }()" 2>&1`;
225 $a =~ s/-e syntax OK\n//g;
226 is($a, <<'EOCODH', "[perl #117311] [PATCH] -l option ('#line ...') does not emit ^Ls in the output");
227 #line 1 "-e"
228 map {
229 #line 1 "-e"
230 eval 0;} ();
231 EOCODH
232
233 # [perl #33752]
234 {
235   my $code = <<"EOCODE";
236 {
237     our \$\x{1e1f}\x{14d}\x{14d};
238 }
239 EOCODE
240   my $deparsed
241    = $deparse->coderef2text(eval "sub { our \$\x{1e1f}\x{14d}\x{14d} }" );
242   s/$ \n//x for $deparsed, $code;
243   is $deparsed, $code, 'our $funny_Unicode_chars';
244 }
245
246 # [perl #62500]
247 $a =
248   `$^X $path "-MO=Deparse" -e "BEGIN{*CORE::GLOBAL::require=sub{1}}" 2>&1`;
249 $a =~ s/-e syntax OK\n//g;
250 is($a, <<'EOCODF', "CORE::GLOBAL::require override causing panick");
251 sub BEGIN {
252     *CORE::GLOBAL::require = sub {
253         1;
254     }
255     ;
256 }
257 EOCODF
258
259 # [perl #91384]
260 $a =
261   `$^X $path "-MO=Deparse" -e "BEGIN{*Acme::Acme:: = *Acme::}" 2>&1`;
262 like($a, qr/-e syntax OK/,
263     "Deparse does not hang when traversing stash circularities");
264
265 # [perl #93990]
266 @] = ();
267 is($deparse->coderef2text(sub{ print "foo@{]}" }),
268 q<{
269     print "foo@{]}";
270 }>, 'curly around to interpolate "@{]}"');
271 is($deparse->coderef2text(sub{ print "foo@{-}" }),
272 q<{
273     print "foo@-";
274 }>, 'no need to curly around to interpolate "@-"');
275
276 # Strict hints in %^H are mercilessly suppressed
277 $a =
278   `$^X $path "-MO=Deparse" -e "use strict; print;" 2>&1`;
279 unlike($a, qr/BEGIN/,
280     "Deparse does not emit strict hh hints");
281
282 # ambient_pragmas should not mess with strict settings.
283 SKIP: {
284     skip "requires 5.11", 1 unless $] >= 5.011;
285     eval q`
286         BEGIN {
287             # Clear out all hints
288             %^H = ();
289             $^H = 0;
290             new B::Deparse -> ambient_pragmas(strict => 'all');
291         }
292         use 5.011;  # should enable strict
293         ok !eval '$do_noT_create_a_variable_with_this_name = 1',
294           'ambient_pragmas do not mess with compiling scope';
295    `;
296 }
297
298 # multiple statements on format lines
299 $a = `$^X $path "-MO=Deparse" -e "format =" -e "\@" -e "x();z()" -e. 2>&1`;
300 $a =~ s/-e syntax OK\n//g;
301 is($a, <<'EOCODH', 'multiple statements on format lines');
302 format STDOUT =
303 @
304 x(); z()
305 .
306 EOCODH
307
308 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path, '-T' ],
309            prog => "format =\n\@\n\$;\n.\n"),
310    <<'EOCODM', '$; on format line';
311 format STDOUT =
312 @
313 $;
314 .
315 EOCODM
316
317 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse,-l', $path ],
318            prog => "format =\n\@\n\$foo\n.\n"),
319    <<'EOCODM', 'formats with -l';
320 format STDOUT =
321 @
322 $foo
323 .
324 EOCODM
325
326 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
327            prog => "{ my \$x; format =\n\@\n\$x\n.\n}"),
328    <<'EOCODN', 'formats nested inside blocks';
329 {
330     my $x;
331     format STDOUT =
332 @
333 $x
334 .
335 }
336 EOCODN
337
338 # CORE::format
339 $a = readpipe qq`$^X $path "-MO=Deparse" -e "use feature q|:all|;`
340              .qq` my sub format; CORE::format =" -e. 2>&1`;
341 like($a, qr/CORE::format/, 'CORE::format when lex format sub is in scope');
342
343 # literal big chars under 'use utf8'
344 is($deparse->coderef2text(sub{ use utf8; /€/; }),
345 '{
346     /\x{20ac}/;
347 }',
348 "qr/euro/");
349
350 # STDERR when deparsing sub calls
351 # For a short while the output included 'While deparsing'
352 $a = `$^X $path "-MO=Deparse" -e "foo()" 2>&1`;
353 $a =~ s/-e syntax OK\n//g;
354 is($a, <<'EOCODI', 'no extra output when deparsing foo()');
355 foo();
356 EOCODI
357
358 # Sub calls compiled before importation
359 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
360              prog => 'BEGIN {
361                        require Test::More;
362                        Test::More::->import;
363                        is(*foo, *foo)
364                      }'),
365      qr/&is\(/,
366     'sub calls compiled before importation of prototype subs';
367
368 # [perl #121050] Prototypes with whitespace
369 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
370            prog => <<'EOCODO'),
371 sub _121050(\$ \$) { }
372 _121050($a,$b);
373 sub _121050empty( ) {}
374 () = _121050empty() + 1;
375 EOCODO
376    <<'EOCODP', '[perl #121050] prototypes with whitespace';
377 sub _121050 (\$ \$) {
378     
379 }
380 _121050 $a, $b;
381 sub _121050empty ( ) {
382     
383 }
384 () = _121050empty + 1;
385 EOCODP
386
387 # CORE::no
388 $a = readpipe qq`$^X $path "-MO=Deparse" -Xe `
389              .qq`"use feature q|:all|; my sub no; CORE::no less" 2>&1`;
390 like($a, qr/my sub no;\n.*CORE::no less;/s,
391     'CORE::no after my sub no');
392
393 # CORE::use
394 $a = readpipe qq`$^X $path "-MO=Deparse" -Xe `
395              .qq`"use feature q|:all|; my sub use; CORE::use less" 2>&1`;
396 like($a, qr/my sub use;\n.*CORE::use less;/s,
397     'CORE::use after my sub use');
398
399 # CORE::__DATA__
400 $a = readpipe qq`$^X $path "-MO=Deparse" -Xe `
401              .qq`"use feature q|:all|; my sub __DATA__; `
402              .qq`CORE::__DATA__" 2>&1`;
403 like($a, qr/my sub __DATA__;\n.*CORE::__DATA__/s,
404     'CORE::__DATA__ after my sub __DATA__');
405
406 # sub declarations
407 $a = readpipe qq`$^X $path "-MO=Deparse" -e "sub foo{}" 2>&1`;
408 like($a, qr/sub foo\s*\{\s+\}/, 'sub declarations');
409 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
410            prog => 'sub f($); sub f($){}'),
411      qr/sub f\s*\(\$\)\s*\{\s*\}/,
412     'predeclared prototyped subs';
413 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
414            prog => 'use Scalar::Util q-weaken-;
415                     sub f($);
416                     BEGIN { weaken($_=\$::{f}) }'),
417      qr/sub f\s*\(\$\)\s*;/,
418     'prototyped stub with weak reference to the stash entry';
419 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
420            prog => 'sub f () { 42 }'),
421      qr/sub f\s*\(\)\s*\{\s*42;\s*\}/,
422     'constant perl sub declaration';
423
424 # BEGIN blocks
425 SKIP : {
426     skip "BEGIN output is wrong on old perls", 1 if $] < 5.021006;
427     my $prog = '
428       BEGIN { pop }
429       {
430         BEGIN { pop }
431         {
432           no overloading;
433           {
434             BEGIN { pop }
435             die
436           }
437         }
438       }';
439     $prog =~ s/\n//g;
440     $a = readpipe qq`$^X $path "-MO=Deparse" -e "$prog" 2>&1`;
441     $a =~ s/-e syntax OK\n//g;
442     is($a, <<'EOCODJ', 'BEGIN blocks');
443 sub BEGIN {
444     pop @ARGV;
445 }
446 {
447     sub BEGIN {
448         pop @ARGV;
449     }
450     {
451         no overloading;
452         {
453             sub BEGIN {
454                 pop @ARGV;
455             }
456             die;
457         }
458     }
459 }
460 EOCODJ
461 }
462 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ], prog => '
463       {
464         {
465           die;
466           BEGIN { pop }
467         }
468         BEGIN { pop }
469       }
470       BEGIN { pop }
471   '), <<'EOCODL', 'BEGIN blocks at the end of their enclosing blocks';
472 {
473     {
474         die;
475         sub BEGIN {
476             pop @ARGV;
477         }
478     }
479     sub BEGIN {
480         pop @ARGV;
481     }
482 }
483 sub BEGIN {
484     pop @ARGV;
485 }
486 EOCODL
487
488 # BEGIN blocks should not be called __ANON__
489 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
490              prog => 'sub BEGIN { } CHECK { delete $::{BEGIN} }'),
491      qr/sub BEGIN/, 'anonymised BEGIN';
492
493 # [perl #115066]
494 my $prog = 'use constant FOO => do { 1 }; no overloading; die';
495 $a = readpipe qq`$^X $path "-MO=-qq,Deparse" -e "$prog" 2>&1`;
496 is($a, <<'EOCODK', '[perl #115066] use statements accidentally nested');
497 use constant ('FOO', do {
498     1
499 });
500 no overloading;
501 die;
502 EOCODK
503
504 # BEGIN blocks inside predeclared subs
505 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
506              prog => '
507                  sub run_tests;
508                  run_tests();
509                  sub run_tests { BEGIN { } die }'),
510      qr/sub run_tests \{\s*sub BEGIN/,
511     'BEGIN block inside predeclared sub';
512
513 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
514              prog => 'package foo; use overload qr=>sub{}'),
515      qr/package foo;\s*use overload/,
516     'package, then use';
517
518 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
519              prog => 'use feature lexical_subs=>; my sub f;sub main::f{}'),
520      qr/^sub main::f \{/m,
521     'sub decl when lex sub is in scope';
522
523 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
524              prog => 'sub foo{foo()}'),
525      qr/^sub foo \{\s+foo\(\)/m,
526     'recursive sub';
527
528 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
529              prog => 'use feature lexical_subs=>state=>;
530                       state sub sb5; sub { sub sb5 { } }'),
531      qr/sub \{\s*\(\);\s*sub sb5 \{/m,
532     'state sub in anon sub but declared outside';
533
534 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
535              prog => 'BEGIN { $::{f}=\!0 }'),
536    "sub BEGIN {\n    \$main::{'f'} = \\1;\n}\n",
537    '&PL_sv_yes constant (used to croak)';
538
539 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path, '-T' ],
540            prog => '$x =~ (1?/$a/:0)'),
541   '$x =~ ($_ =~ /$a/);'."\n",
542   '$foo =~ <branch-folded match> under taint mode';
543
544 unlike runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path, '-w' ],
545                prog => 'BEGIN { undef &foo }'),
546        qr'Use of uninitialized value',
547       'no warnings for undefined sub';
548
549 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
550     prog => 'sub f { 1; } BEGIN { *g = \&f; }'),
551     "sub f {\n    1;\n}\nsub BEGIN {\n    *g = \\&f;\n}\n",
552     "sub glob alias shouldn't impede emitting original sub";
553
554 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
555     prog => 'package Foo; sub f { 1; } BEGIN { *g = \&f; }'),
556     "package Foo;\nsub f {\n    1;\n}\nsub BEGIN {\n    *g = \\&f;\n}\n",
557     "sub glob alias outside main shouldn't impede emitting original sub";
558
559 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
560     prog => 'package Foo; sub f { 1; } BEGIN { *Bar::f = \&f; }'),
561     "package Foo;\nsub f {\n    1;\n}\nsub BEGIN {\n    *Bar::f = \\&f;\n}\n",
562     "sub glob alias in separate package shouldn't impede emitting original sub";
563
564
565 done_testing($tests);
566
567 __DATA__
568 # [perl #120950] Previously on a 2nd instance succeeded
569 # y/uni/code/
570 tr/\x{345}/\x{370}/;
571 ####
572 # y/uni/code/  [perl #120950] This 2nd instance succeeds
573 tr/\x{345}/\x{370}/;
574 ####
575 # A constant
576 1;
577 ####
578 # Constants in a block
579 # CONTEXT no warnings;
580 {
581     '???';
582     2;
583 }
584 ####
585 # List of constants in void context
586 # CONTEXT no warnings;
587 (1,2,3);
588 0;
589 >>>>
590 '???', '???', '???';
591 0;
592 ####
593 # Lexical and simple arithmetic
594 my $test;
595 ++$test and $test /= 2;
596 >>>>
597 my $test;
598 $test /= 2 if ++$test;
599 ####
600 # list x
601 -((1, 2) x 2);
602 ####
603 # Assignment to list x
604 ((undef) x 3) = undef;
605 ####
606 # lvalue sub
607 {
608     my $test = sub : lvalue {
609         my $x;
610     }
611     ;
612 }
613 ####
614 # method
615 {
616     my $test = sub : method {
617         my $x;
618     }
619     ;
620 }
621 ####
622 # anonsub attrs at statement start
623 my $x = do { +sub : lvalue { my $y; } };
624 my $z = do { foo: +sub : method { my $a; } };
625 ####
626 # block with continue
627 {
628     234;
629 }
630 continue {
631     123;
632 }
633 ####
634 # lexical and package scalars
635 my $x;
636 print $main::x;
637 ####
638 # lexical and package arrays
639 my @x;
640 print $main::x[1];
641 print \my @a;
642 ####
643 # lexical and package hashes
644 my %x;
645 $x{warn()};
646 ####
647 # our (LIST)
648 our($foo, $bar, $baz);
649 ####
650 # CONTEXT { package Dog } use feature "state";
651 # variables with declared classes
652 my Dog $spot;
653 our Dog $spotty;
654 state Dog $spotted;
655 my Dog @spot;
656 our Dog @spotty;
657 state Dog @spotted;
658 my Dog %spot;
659 our Dog %spotty;
660 state Dog %spotted;
661 my Dog ($foo, @bar, %baz);
662 our Dog ($phoo, @barr, %bazz);
663 state Dog ($fough, @barre, %bazze);
664 ####
665 # local our
666 local our $rhubarb;
667 local our($rhu, $barb);
668 ####
669 # <>
670 my $foo;
671 $_ .= <> . <ARGV> . <$foo>;
672 <$foo>;
673 <${foo}>;
674 <$ foo>;
675 >>>>
676 my $foo;
677 $_ .= readline(ARGV) . readline(ARGV) . readline($foo);
678 readline $foo;
679 glob $foo;
680 glob $foo;
681 ####
682 # readline
683 readline 'FH';
684 readline *$_;
685 readline *{$_};
686 readline ${"a"};
687 >>>>
688 readline 'FH';
689 readline *$_;
690 readline *{$_;};
691 readline ${'a';};
692 ####
693 # <<>>
694 $_ = <<>>;
695 ####
696 # \x{}
697 my $foo = "Ab\x{100}\200\x{200}\237Cd\000Ef\x{1000}\cA\x{2000}\cZ";
698 my $bar = "\x{100}";
699 ####
700 # Latin-1 chars
701 # TODO ? ord("A") != 65 && "EBCDIC"
702 my $baz = "B\366\x{100}";
703 my $bba = qr/B\366\x{100}/;
704 ####
705 # s///e
706 s/x/'y';/e;
707 s/x/$a;/e;
708 s/x/complex_expression();/e;
709 ####
710 # block
711 { my $x; }
712 ####
713 # while 1
714 while (1) { my $k; }
715 ####
716 # trailing for
717 my ($x,@a);
718 $x=1 for @a;
719 >>>>
720 my($x, @a);
721 $x = 1 foreach (@a);
722 ####
723 # 2 arguments in a 3 argument for
724 for (my $i = 0; $i < 2;) {
725     my $z = 1;
726 }
727 ####
728 # 3 argument for
729 for (my $i = 0; $i < 2; ++$i) {
730     my $z = 1;
731 }
732 ####
733 # 3 argument for again
734 for (my $i = 0; $i < 2; ++$i) {
735     my $z = 1;
736 }
737 ####
738 # 3-argument for with inverted condition
739 for (my $i; not $i;) {
740     die;
741 }
742 for (my $i; not $i; ++$i) {
743     die;
744 }
745 for (my $a; not +($1 || 2) ** 2;) {
746     die;
747 }
748 Something_to_put_the_loop_in_void_context();
749 ####
750 # while/continue
751 my $i;
752 while ($i) { my $z = 1; } continue { $i = 99; }
753 ####
754 # foreach with my
755 foreach my $i (1, 2) {
756     my $z = 1;
757 }
758 ####
759 # OPTIONS -p
760 # foreach with my under -p
761 foreach my $i (1) {
762     die;
763 }
764 ####
765 # foreach
766 my $i;
767 foreach $i (1, 2) {
768     my $z = 1;
769 }
770 ####
771 # foreach, 2 mys
772 my $i;
773 foreach my $i (1, 2) {
774     my $z = 1;
775 }
776 ####
777 # foreach with our
778 foreach our $i (1, 2) {
779     my $z = 1;
780 }
781 ####
782 # foreach with my and our
783 my $i;
784 foreach our $i (1, 2) {
785     my $z = 1;
786 }
787 ####
788 # foreach with state
789 # CONTEXT use feature "state";
790 foreach state $i (1, 2) {
791     state $z = 1;
792 }
793 ####
794 # foreach with sub call
795 foreach $_ (hcaerof()) {
796     ();
797 }
798 ####
799 # reverse sort
800 my @x;
801 print reverse sort(@x);
802 ####
803 # sort with cmp
804 my @x;
805 print((sort {$b cmp $a} @x));
806 ####
807 # reverse sort with block
808 my @x;
809 print((reverse sort {$b <=> $a} @x));
810 ####
811 # foreach reverse
812 our @a;
813 print $_ foreach (reverse @a);
814 ####
815 # foreach reverse (not inplace)
816 our @a;
817 print $_ foreach (reverse 1, 2..5);
818 ####
819 # bug #38684
820 our @ary;
821 @ary = split(' ', 'foo', 0);
822 ####
823 my @ary;
824 @ary = split(' ', 'foo', 0);
825 ####
826 # Split to our array
827 our @array = split(//, 'foo', 0);
828 ####
829 # Split to my array
830 my @array  = split(//, 'foo', 0);
831 ####
832 our @array;
833 my $c;
834 @array = split(/x(?{ $c++; })y/, 'foo', 0);
835 ####
836 my($x, $y, $p);
837 our $c;
838 ($x, $y) = split(/$p(?{ $c++; })y/, 'foo', 2);
839 ####
840 our @ary;
841 my $pat;
842 @ary = split(/$pat/, 'foo', 0);
843 ####
844 my @ary;
845 our $pat;
846 @ary = split(/$pat/, 'foo', 0);
847 ####
848 our @array;
849 my $pat;
850 local @array = split(/$pat/, 'foo', 0);
851 ####
852 our $pat;
853 my @array  = split(/$pat/, 'foo', 0);
854 ####
855 # bug #40055
856 do { () }; 
857 ####
858 # bug #40055
859 do { my $x = 1; $x }; 
860 ####
861 # <20061012113037.GJ25805@c4.convolution.nl>
862 my $f = sub {
863     +{[]};
864 } ;
865 ####
866 # bug #43010
867 '!@$%'->();
868 ####
869 # bug #43010
870 ::();
871 ####
872 # bug #43010
873 '::::'->();
874 ####
875 # bug #43010
876 &::::;
877 ####
878 # [perl #77172]
879 package rt77172;
880 sub foo {} foo & & & foo;
881 >>>>
882 package rt77172;
883 foo(&{&} & foo());
884 ####
885 # variables as method names
886 my $bar;
887 'Foo'->$bar('orz');
888 'Foo'->$bar('orz') = 'a stranger stranger than before';
889 ####
890 # constants as method names
891 'Foo'->bar('orz');
892 ####
893 # constants as method names without ()
894 'Foo'->bar;
895 ####
896 # [perl #47359] "indirect" method call notation
897 our @bar;
898 foo{@bar}+1,->foo;
899 (foo{@bar}+1),foo();
900 foo{@bar}1 xor foo();
901 >>>>
902 our @bar;
903 (foo { @bar } 1)->foo;
904 (foo { @bar } 1), foo();
905 foo { @bar } 1 xor foo();
906 ####
907 # indirops with blocks
908 # CONTEXT use 5.01;
909 print {*STDOUT;} 'foo';
910 printf {*STDOUT;} 'foo';
911 say {*STDOUT;} 'foo';
912 system {'foo';} '-foo';
913 exec {'foo';} '-foo';
914 ####
915 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
916 # CONTEXT use feature ':5.10';
917 # say
918 say 'foo';
919 ####
920 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
921 # CONTEXT use 5.10.0;
922 # say in the context of use 5.10.0
923 say 'foo';
924 ####
925 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
926 # say with use 5.10.0
927 use 5.10.0;
928 say 'foo';
929 >>>>
930 no feature ':all';
931 use feature ':5.10';
932 say 'foo';
933 ####
934 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
935 # say with use feature ':5.10';
936 use feature ':5.10';
937 say 'foo';
938 >>>>
939 use feature 'say', 'state', 'switch';
940 say 'foo';
941 ####
942 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
943 # CONTEXT use feature ':5.10';
944 # say with use 5.10.0 in the context of use feature
945 use 5.10.0;
946 say 'foo';
947 >>>>
948 no feature ':all';
949 use feature ':5.10';
950 say 'foo';
951 ####
952 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
953 # CONTEXT use 5.10.0;
954 # say with use feature ':5.10' in the context of use 5.10.0
955 use feature ':5.10';
956 say 'foo';
957 >>>>
958 say 'foo';
959 ####
960 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
961 # CONTEXT use feature ':5.15';
962 # __SUB__
963 __SUB__;
964 ####
965 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
966 # CONTEXT use 5.15.0;
967 # __SUB__ in the context of use 5.15.0
968 __SUB__;
969 ####
970 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
971 # __SUB__ with use 5.15.0
972 use 5.15.0;
973 __SUB__;
974 >>>>
975 no feature ':all';
976 use feature ':5.16';
977 __SUB__;
978 ####
979 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
980 # __SUB__ with use feature ':5.15';
981 use feature ':5.15';
982 __SUB__;
983 >>>>
984 use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
985 __SUB__;
986 ####
987 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
988 # CONTEXT use feature ':5.15';
989 # __SUB__ with use 5.15.0 in the context of use feature
990 use 5.15.0;
991 __SUB__;
992 >>>>
993 no feature ':all';
994 use feature ':5.16';
995 __SUB__;
996 ####
997 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
998 # CONTEXT use 5.15.0;
999 # __SUB__ with use feature ':5.15' in the context of use 5.15.0
1000 use feature ':5.15';
1001 __SUB__;
1002 >>>>
1003 __SUB__;
1004 ####
1005 # SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
1006 # CONTEXT use feature ':5.10';
1007 # state vars
1008 state $x = 42;
1009 ####
1010 # SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
1011 # CONTEXT use feature ':5.10';
1012 # state var assignment
1013 {
1014     my $y = (state $x = 42);
1015 }
1016 ####
1017 # SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
1018 # CONTEXT use feature ':5.10';
1019 # state vars in anonymous subroutines
1020 $a = sub {
1021     state $x;
1022     return $x++;
1023 }
1024 ;
1025 ####
1026 # SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
1027 # each @array;
1028 each @ARGV;
1029 each @$a;
1030 ####
1031 # SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
1032 # keys @array; values @array
1033 keys @$a if keys @ARGV;
1034 values @ARGV if values @$a;
1035 ####
1036 # Anonymous arrays and hashes, and references to them
1037 my $a = {};
1038 my $b = \{};
1039 my $c = [];
1040 my $d = \[];
1041 ####
1042 # SKIP ?$] < 5.010 && "smartmatch and given/when not implemented on this Perl version"
1043 # CONTEXT use feature ':5.10'; no warnings 'experimental::smartmatch';
1044 # implicit smartmatch in given/when
1045 given ('foo') {
1046     when ('bar') { continue; }
1047     when ($_ ~~ 'quux') { continue; }
1048     default { 0; }
1049 }
1050 ####
1051 # conditions in elsifs (regression in change #33710 which fixed bug #37302)
1052 if ($a) { x(); }
1053 elsif ($b) { x(); }
1054 elsif ($a and $b) { x(); }
1055 elsif ($a or $b) { x(); }
1056 else { x(); }
1057 ####
1058 # interpolation in regexps
1059 my($y, $t);
1060 /x${y}z$t/;
1061 ####
1062 # TODO new undocumented cpan-bug #33708
1063 # cpan-bug #33708
1064 %{$_ || {}}
1065 ####
1066 # TODO hash constants not yet fixed
1067 # cpan-bug #33708
1068 use constant H => { "#" => 1 }; H->{"#"}
1069 ####
1070 # TODO optimized away 0 not yet fixed
1071 # cpan-bug #33708
1072 foreach my $i (@_) { 0 }
1073 ####
1074 # tests with not, not optimized
1075 my $c;
1076 x() unless $a;
1077 x() if not $a and $b;
1078 x() if $a and not $b;
1079 x() unless not $a and $b;
1080 x() unless $a and not $b;
1081 x() if not $a or $b;
1082 x() if $a or not $b;
1083 x() unless not $a or $b;
1084 x() unless $a or not $b;
1085 x() if $a and not $b and $c;
1086 x() if not $a and $b and not $c;
1087 x() unless $a and not $b and $c;
1088 x() unless not $a and $b and not $c;
1089 x() if $a or not $b or $c;
1090 x() if not $a or $b or not $c;
1091 x() unless $a or not $b or $c;
1092 x() unless not $a or $b or not $c;
1093 ####
1094 # tests with not, optimized
1095 my $c;
1096 x() if not $a;
1097 x() unless not $a;
1098 x() if not $a and not $b;
1099 x() unless not $a and not $b;
1100 x() if not $a or not $b;
1101 x() unless not $a or not $b;
1102 x() if not $a and not $b and $c;
1103 x() unless not $a and not $b and $c;
1104 x() if not $a or not $b or $c;
1105 x() unless not $a or not $b or $c;
1106 x() if not $a and not $b and not $c;
1107 x() unless not $a and not $b and not $c;
1108 x() if not $a or not $b or not $c;
1109 x() unless not $a or not $b or not $c;
1110 x() unless not $a or not $b or not $c;
1111 >>>>
1112 my $c;
1113 x() unless $a;
1114 x() if $a;
1115 x() unless $a or $b;
1116 x() if $a or $b;
1117 x() unless $a and $b;
1118 x() if $a and $b;
1119 x() if not $a || $b and $c;
1120 x() unless not $a || $b and $c;
1121 x() if not $a && $b or $c;
1122 x() unless not $a && $b or $c;
1123 x() unless $a or $b or $c;
1124 x() if $a or $b or $c;
1125 x() unless $a and $b and $c;
1126 x() if $a and $b and $c;
1127 x() unless not $a && $b && $c;
1128 ####
1129 # tests that should be constant folded
1130 x() if 1;
1131 x() if GLIPP;
1132 x() if !GLIPP;
1133 x() if GLIPP && GLIPP;
1134 x() if !GLIPP || GLIPP;
1135 x() if do { GLIPP };
1136 x() if do { no warnings 'void'; 5; GLIPP };
1137 x() if do { !GLIPP };
1138 if (GLIPP) { x() } else { z() }
1139 if (!GLIPP) { x() } else { z() }
1140 if (GLIPP) { x() } elsif (GLIPP) { z() }
1141 if (!GLIPP) { x() } elsif (GLIPP) { z() }
1142 if (GLIPP) { x() } elsif (!GLIPP) { z() }
1143 if (!GLIPP) { x() } elsif (!GLIPP) { z() }
1144 if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (GLIPP) { t() }
1145 if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
1146 if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
1147 >>>>
1148 x();
1149 x();
1150 '???';
1151 x();
1152 x();
1153 x();
1154 x();
1155 do {
1156     '???'
1157 };
1158 do {
1159     x()
1160 };
1161 do {
1162     z()
1163 };
1164 do {
1165     x()
1166 };
1167 do {
1168     z()
1169 };
1170 do {
1171     x()
1172 };
1173 '???';
1174 do {
1175     t()
1176 };
1177 '???';
1178 !1;
1179 ####
1180 # TODO constant deparsing has been backed out for 5.12
1181 # XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
1182 # tests that shouldn't be constant folded
1183 # It might be fundamentally impossible to make this work on ithreads, in which
1184 # case the TODO should become a SKIP
1185 x() if $a;
1186 if ($a == 1) { x() } elsif ($b == 2) { z() }
1187 if (do { foo(); GLIPP }) { x() }
1188 if (do { $a++; GLIPP }) { x() }
1189 >>>>
1190 x() if $a;
1191 if ($a == 1) { x(); } elsif ($b == 2) { z(); }
1192 if (do { foo(); GLIPP }) { x(); }
1193 if (do { ++$a; GLIPP }) { x(); }
1194 ####
1195 # TODO constant deparsing has been backed out for 5.12
1196 # tests for deparsing constants
1197 warn PI;
1198 ####
1199 # TODO constant deparsing has been backed out for 5.12
1200 # tests for deparsing imported constants
1201 warn O_TRUNC;
1202 ####
1203 # TODO constant deparsing has been backed out for 5.12
1204 # tests for deparsing re-exported constants
1205 warn O_CREAT;
1206 ####
1207 # TODO constant deparsing has been backed out for 5.12
1208 # tests for deparsing imported constants that got deleted from the original namespace
1209 warn O_APPEND;
1210 ####
1211 # TODO constant deparsing has been backed out for 5.12
1212 # XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
1213 # tests for deparsing constants which got turned into full typeglobs
1214 # It might be fundamentally impossible to make this work on ithreads, in which
1215 # case the TODO should become a SKIP
1216 warn O_EXCL;
1217 eval '@Fcntl::O_EXCL = qw/affe tiger/;';
1218 warn O_EXCL;
1219 ####
1220 # TODO constant deparsing has been backed out for 5.12
1221 # tests for deparsing of blessed constant with overloaded numification
1222 warn OVERLOADED_NUMIFICATION;
1223 ####
1224 # strict
1225 no strict;
1226 print $x;
1227 use strict 'vars';
1228 print $main::x;
1229 use strict 'subs';
1230 print $main::x;
1231 use strict 'refs';
1232 print $main::x;
1233 no strict 'vars';
1234 $x;
1235 ####
1236 # TODO Subsets of warnings could be encoded textually, rather than as bitflips.
1237 # subsets of warnings
1238 no warnings 'deprecated';
1239 my $x;
1240 ####
1241 # TODO Better test for CPAN #33708 - the deparsed code has different behaviour
1242 # CPAN #33708
1243 use strict;
1244 no warnings;
1245
1246 foreach (0..3) {
1247     my $x = 2;
1248     {
1249         my $x if 0;
1250         print ++$x, "\n";
1251     }
1252 }
1253 ####
1254 # no attribute list
1255 my $pi = 4;
1256 ####
1257 # SKIP ?$] > 5.013006 && ":= is now a syntax error"
1258 # := treated as an empty attribute list
1259 no warnings;
1260 my $pi := 4;
1261 >>>>
1262 no warnings;
1263 my $pi = 4;
1264 ####
1265 # : = empty attribute list
1266 my $pi : = 4;
1267 >>>>
1268 my $pi = 4;
1269 ####
1270 # in place sort
1271 our @a;
1272 my @b;
1273 @a = sort @a;
1274 @b = sort @b;
1275 ();
1276 ####
1277 # in place reverse
1278 our @a;
1279 my @b;
1280 @a = reverse @a;
1281 @b = reverse @b;
1282 ();
1283 ####
1284 # #71870 Use of uninitialized value in bitwise and B::Deparse
1285 my($r, $s, @a);
1286 @a = split(/foo/, $s, 0);
1287 $r = qr/foo/;
1288 @a = split(/$r/, $s, 0);
1289 ();
1290 ####
1291 # package declaration before label
1292 {
1293     package Foo;
1294     label: print 123;
1295 }
1296 ####
1297 # shift optimisation
1298 shift;
1299 >>>>
1300 shift();
1301 ####
1302 # shift optimisation
1303 shift @_;
1304 ####
1305 # shift optimisation
1306 pop;
1307 >>>>
1308 pop();
1309 ####
1310 # shift optimisation
1311 pop @_;
1312 ####
1313 #[perl #20444]
1314 "foo" =~ (1 ? /foo/ : /bar/);
1315 "foo" =~ (1 ? y/foo// : /bar/);
1316 "foo" =~ (1 ? y/foo//r : /bar/);
1317 "foo" =~ (1 ? s/foo// : /bar/);
1318 >>>>
1319 'foo' =~ ($_ =~ /foo/);
1320 'foo' =~ ($_ =~ tr/fo//);
1321 'foo' =~ ($_ =~ tr/fo//r);
1322 'foo' =~ ($_ =~ s/foo//);
1323 ####
1324 # The fix for [perl #20444] broke this.
1325 'foo' =~ do { () };
1326 ####
1327 # [perl #81424] match against aelemfast_lex
1328 my @s;
1329 print /$s[1]/;
1330 ####
1331 # /$#a/
1332 print /$#main::a/;
1333 ####
1334 # /@array/
1335 our @a;
1336 my @b;
1337 print /@a/;
1338 print /@b/;
1339 print qr/@a/;
1340 print qr/@b/;
1341 ####
1342 # =~ QR_CONSTANT
1343 use constant QR_CONSTANT => qr/a/soupmix;
1344 '' =~ QR_CONSTANT;
1345 >>>>
1346 '' =~ /a/impsux;
1347 ####
1348 # $lexical =~ //
1349 my $x;
1350 $x =~ //;
1351 ####
1352 # [perl #91318] /regexp/applaud
1353 print /a/a, s/b/c/a;
1354 print /a/aa, s/b/c/aa;
1355 print /a/p, s/b/c/p;
1356 print /a/l, s/b/c/l;
1357 print /a/u, s/b/c/u;
1358 {
1359     use feature "unicode_strings";
1360     print /a/d, s/b/c/d;
1361 }
1362 {
1363     use re "/u";
1364     print /a/d, s/b/c/d;
1365 }
1366 {
1367     use 5.012;
1368     print /a/d, s/b/c/d;
1369 }
1370 >>>>
1371 print /a/a, s/b/c/a;
1372 print /a/aa, s/b/c/aa;
1373 print /a/p, s/b/c/p;
1374 print /a/l, s/b/c/l;
1375 print /a/u, s/b/c/u;
1376 {
1377     use feature 'unicode_strings';
1378     print /a/d, s/b/c/d;
1379 }
1380 {
1381     BEGIN { $^H{'reflags'}         = '0';
1382             $^H{'reflags_charset'} = '2'; }
1383     print /a/d, s/b/c/d;
1384 }
1385 {
1386     no feature ':all';
1387     use feature ':5.12';
1388     print /a/d, s/b/c/d;
1389 }
1390 ####
1391 # all the flags (qr//)
1392 $_ = qr/X/m;
1393 $_ = qr/X/s;
1394 $_ = qr/X/i;
1395 $_ = qr/X/x;
1396 $_ = qr/X/p;
1397 $_ = qr/X/o;
1398 $_ = qr/X/u;
1399 $_ = qr/X/a;
1400 $_ = qr/X/l;
1401 $_ = qr/X/n;
1402 ####
1403 use feature 'unicode_strings';
1404 $_ = qr/X/d;
1405 ####
1406 # all the flags (m//)
1407 /X/m;
1408 /X/s;
1409 /X/i;
1410 /X/x;
1411 /X/p;
1412 /X/o;
1413 /X/u;
1414 /X/a;
1415 /X/l;
1416 /X/n;
1417 /X/g;
1418 /X/cg;
1419 ####
1420 use feature 'unicode_strings';
1421 /X/d;
1422 ####
1423 # all the flags (s///)
1424 s/X//m;
1425 s/X//s;
1426 s/X//i;
1427 s/X//x;
1428 s/X//p;
1429 s/X//o;
1430 s/X//u;
1431 s/X//a;
1432 s/X//l;
1433 s/X//n;
1434 s/X//g;
1435 s/X/'';/e;
1436 s/X//r;
1437 ####
1438 use feature 'unicode_strings';
1439 s/X//d;
1440 ####
1441 # tr/// with all the flags: empty replacement
1442 tr/B-G//;
1443 tr/B-G//c;
1444 tr/B-G//d;
1445 tr/B-G//s;
1446 tr/B-G//cd;
1447 tr/B-G//ds;
1448 tr/B-G//cs;
1449 tr/B-G//cds;
1450 tr/B-G//r;
1451 ####
1452 # tr/// with all the flags: short replacement
1453 tr/B-G/b/;
1454 tr/B-G/b/c;
1455 tr/B-G/b/d;
1456 tr/B-G/b/s;
1457 tr/B-G/b/cd;
1458 tr/B-G/b/ds;
1459 tr/B-G/b/cs;
1460 tr/B-G/b/cds;
1461 tr/B-G/b/r;
1462 ####
1463 # tr/// with all the flags: equal length replacement
1464 tr/B-G/b-g/;
1465 tr/B-G/b-g/c;
1466 tr/B-G/b-g/s;
1467 tr/B-G/b-g/cs;
1468 tr/B-G/b-g/r;
1469 ####
1470 # tr with extended table (/c)
1471 tr/\000-\375/AB/c;
1472 tr/\000-\375/A-C/c;
1473 tr/\000-\375/A-D/c;
1474 tr/\000-\375/A-I/c;
1475 tr/\000-\375/AB/cd;
1476 tr/\000-\375/A-C/cd;
1477 tr/\000-\375/A-D/cd;
1478 tr/\000-\375/A-I/cd;
1479 tr/\000-\375/AB/cds;
1480 tr/\000-\375/A-C/cds;
1481 tr/\000-\375/A-D/cds;
1482 tr/\000-\375/A-I/cds;
1483 ####
1484 # [perl #119807] s//\(3)/ge should not warn when deparsed (\3 warns)
1485 s/foo/\(3);/eg;
1486 ####
1487 # [perl #115256]
1488 "" =~ /a(?{ print q|
1489 |})/;
1490 >>>>
1491 '' =~ /a(?{ print "\n"; })/;
1492 ####
1493 # [perl #123217]
1494 $_ = qr/(??{<<END})/
1495 f.o
1496 b.r
1497 END
1498 >>>>
1499 $_ = qr/(??{ "f.o\nb.r\n"; })/;
1500 ####
1501 # More regexp code block madness
1502 my($b, @a);
1503 /(?{ die $b; })/;
1504 /a(?{ die $b; })a/;
1505 /$a(?{ die $b; })/;
1506 /@a(?{ die $b; })/;
1507 /(??{ die $b; })/;
1508 /a(??{ die $b; })a/;
1509 /$a(??{ die $b; })/;
1510 /@a(??{ die $b; })/;
1511 qr/(?{ die $b; })/;
1512 qr/a(?{ die $b; })a/;
1513 qr/$a(?{ die $b; })/;
1514 qr/@a(?{ die $b; })/;
1515 qr/(??{ die $b; })/;
1516 qr/a(??{ die $b; })a/;
1517 qr/$a(??{ die $b; })/;
1518 qr/@a(??{ die $b; })/;
1519 s/(?{ die $b; })//;
1520 s/a(?{ die $b; })a//;
1521 s/$a(?{ die $b; })//;
1522 s/@a(?{ die $b; })//;
1523 s/(??{ die $b; })//;
1524 s/a(??{ die $b; })a//;
1525 s/$a(??{ die $b; })//;
1526 s/@a(??{ die $b; })//;
1527 ####
1528 # /(?x)<newline><tab>/
1529 /(?x)
1530         /;
1531 ####
1532 # y///r
1533 tr/a/b/r + $a =~ tr/p/q/r;
1534 ####
1535 # y///d in list [perl #119815]
1536 () = tr/a//d;
1537 ####
1538 # [perl #90898]
1539 <a,>;
1540 glob 'a,';
1541 >>>>
1542 glob 'a,';
1543 glob 'a,';
1544 ####
1545 # [perl #91008]
1546 # SKIP ?$] >= 5.023 && "autoderef deleted in this Perl version"
1547 # CONTEXT no warnings 'experimental::autoderef';
1548 each $@;
1549 keys $~;
1550 values $!;
1551 ####
1552 # readpipe with complex expression
1553 readpipe $a + $b;
1554 ####
1555 # aelemfast
1556 $b::a[0] = 1;
1557 ####
1558 # aelemfast for a lexical
1559 my @a;
1560 $a[0] = 1;
1561 ####
1562 # feature features without feature
1563 # CONTEXT no warnings 'experimental::smartmatch';
1564 CORE::state $x;
1565 CORE::say $x;
1566 CORE::given ($x) {
1567     CORE::when (3) {
1568         continue;
1569     }
1570     CORE::default {
1571         CORE::break;
1572     }
1573 }
1574 CORE::evalbytes '';
1575 () = CORE::__SUB__;
1576 () = CORE::fc $x;
1577 ####
1578 # feature features when feature has been disabled by use VERSION
1579 # CONTEXT no warnings 'experimental::smartmatch';
1580 use feature (sprintf(":%vd", $^V));
1581 use 1;
1582 CORE::say $_;
1583 CORE::state $x;
1584 CORE::given ($x) {
1585     CORE::when (3) {
1586         continue;
1587     }
1588     CORE::default {
1589         CORE::break;
1590     }
1591 }
1592 CORE::evalbytes '';
1593 () = CORE::__SUB__;
1594 >>>>
1595 CORE::say $_;
1596 CORE::state $x;
1597 CORE::given ($x) {
1598     CORE::when (3) {
1599         continue;
1600     }
1601     CORE::default {
1602         CORE::break;
1603     }
1604 }
1605 CORE::evalbytes '';
1606 () = CORE::__SUB__;
1607 ####
1608 # (the above test with CONTEXT, and the output is equivalent but different)
1609 # CONTEXT use feature ':5.10'; no warnings 'experimental::smartmatch';
1610 # feature features when feature has been disabled by use VERSION
1611 use feature (sprintf(":%vd", $^V));
1612 use 1;
1613 CORE::say $_;
1614 CORE::state $x;
1615 CORE::given ($x) {
1616     CORE::when (3) {
1617         continue;
1618     }
1619     CORE::default {
1620         CORE::break;
1621     }
1622 }
1623 CORE::evalbytes '';
1624 () = CORE::__SUB__;
1625 >>>>
1626 no feature ':all';
1627 use feature ':default';
1628 CORE::say $_;
1629 CORE::state $x;
1630 CORE::given ($x) {
1631     CORE::when (3) {
1632         continue;
1633     }
1634     CORE::default {
1635         CORE::break;
1636     }
1637 }
1638 CORE::evalbytes '';
1639 () = CORE::__SUB__;
1640 ####
1641 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
1642 # lexical subroutines and keywords of the same name
1643 # CONTEXT use feature 'lexical_subs', 'switch'; no warnings 'experimental';
1644 my sub default;
1645 my sub else;
1646 my sub elsif;
1647 my sub for;
1648 my sub foreach;
1649 my sub given;
1650 my sub if;
1651 my sub m;
1652 my sub no;
1653 my sub package;
1654 my sub q;
1655 my sub qq;
1656 my sub qr;
1657 my sub qx;
1658 my sub require;
1659 my sub s;
1660 my sub sub;
1661 my sub tr;
1662 my sub unless;
1663 my sub until;
1664 my sub use;
1665 my sub when;
1666 my sub while;
1667 CORE::default { die; }
1668 CORE::if ($1) { die; }
1669 CORE::if ($1) { die; }
1670 CORE::elsif ($1) { die; }
1671 CORE::else { die; }
1672 CORE::for (die; $1; die) { die; }
1673 CORE::foreach $_ (1 .. 10) { die; }
1674 die CORE::foreach (1);
1675 CORE::given ($1) { die; }
1676 CORE::m[/];
1677 CORE::m?/?;
1678 CORE::package foo;
1679 CORE::no strict;
1680 () = (CORE::q['], CORE::qq["$_], CORE::qr//, CORE::qx[`]);
1681 CORE::require 1;
1682 CORE::s///;
1683 () = CORE::sub { die; } ;
1684 CORE::tr///;
1685 CORE::unless ($1) { die; }
1686 CORE::until ($1) { die; }
1687 die CORE::until $1;
1688 CORE::use strict;
1689 CORE::when ($1 ~~ $2) { die; }
1690 CORE::while ($1) { die; }
1691 die CORE::while $1;
1692 ####
1693 # Feature hints
1694 use feature 'current_sub', 'evalbytes';
1695 print;
1696 use 1;
1697 print;
1698 use 5.014;
1699 print;
1700 no feature 'unicode_strings';
1701 print;
1702 >>>>
1703 use feature 'current_sub', 'evalbytes';
1704 print $_;
1705 no feature ':all';
1706 use feature ':default';
1707 print $_;
1708 no feature ':all';
1709 use feature ':5.12';
1710 print $_;
1711 no feature 'unicode_strings';
1712 print $_;
1713 ####
1714 # $#- $#+ $#{%} etc.
1715 my @x;
1716 @x = ($#{`}, $#{~}, $#{!}, $#{@}, $#{$}, $#{%}, $#{^}, $#{&}, $#{*});
1717 @x = ($#{(}, $#{)}, $#{[}, $#{{}, $#{]}, $#{}}, $#{'}, $#{"}, $#{,});
1718 @x = ($#{<}, $#{.}, $#{>}, $#{/}, $#{?}, $#{=}, $#+, $#{\}, $#{|}, $#-);
1719 @x = ($#{;}, $#{:}, $#{1}), $#_;
1720 ####
1721 # [perl #86060] $( $| $) in regexps need braces
1722 /${(}/;
1723 /${|}/;
1724 /${)}/;
1725 /${(}${|}${)}/;
1726 /@{+}@{-}/;
1727 ####
1728 # ()[...]
1729 my(@a) = ()[()];
1730 ####
1731 # sort(foo(bar))
1732 # sort(foo(bar)) is interpreted as sort &foo(bar)
1733 # sort foo(bar) is interpreted as sort foo bar
1734 # parentheses are not optional in this case
1735 print sort(foo('bar'));
1736 >>>>
1737 print sort(foo('bar'));
1738 ####
1739 # substr assignment
1740 substr(my $a, 0, 0) = (foo(), bar());
1741 $a++;
1742 ####
1743 # This following line works around an unfixed bug that we are not trying to 
1744 # test for here:
1745 # CONTEXT BEGIN { $^H{a} = "b"; delete $^H{a} } # make %^H localised
1746 # hint hash
1747 BEGIN { $^H{'foo'} = undef; }
1748 {
1749  BEGIN { $^H{'bar'} = undef; }
1750  {
1751   BEGIN { $^H{'baz'} = undef; }
1752   {
1753    print $_;
1754   }
1755   print $_;
1756  }
1757  print $_;
1758 }
1759 BEGIN { $^H{q[']} = '('; }
1760 print $_;
1761 ####
1762 # This following line works around an unfixed bug that we are not trying to 
1763 # test for here:
1764 # CONTEXT BEGIN { $^H{a} = "b"; delete $^H{a} } # make %^H localised
1765 # hint hash changes that serialise the same way with sort %hh
1766 BEGIN { $^H{'a'} = 'b'; }
1767 {
1768  BEGIN { $^H{'b'} = 'a'; delete $^H{'a'}; }
1769  print $_;
1770 }
1771 print $_;
1772 ####
1773 # [perl #47361] do({}) and do +{} (variants of do-file)
1774 do({});
1775 do +{};
1776 sub foo::do {}
1777 package foo;
1778 CORE::do({});
1779 CORE::do +{};
1780 >>>>
1781 do({});
1782 do({});
1783 package foo;
1784 CORE::do({});
1785 CORE::do({});
1786 ####
1787 # [perl #77096] functions that do not follow the llafr
1788 () = (return 1) + time;
1789 () = (return ($1 + $2) * $3) + time;
1790 () = (return ($a xor $b)) + time;
1791 () = (do 'file') + time;
1792 () = (do ($1 + $2) * $3) + time;
1793 () = (do ($1 xor $2)) + time;
1794 () = (goto 1) + 3;
1795 () = (require 'foo') + 3;
1796 () = (require foo) + 3;
1797 () = (CORE::dump 1) + 3;
1798 () = (last 1) + 3;
1799 () = (next 1) + 3;
1800 () = (redo 1) + 3;
1801 () = (-R $_) + 3;
1802 () = (-W $_) + 3;
1803 () = (-X $_) + 3;
1804 () = (-r $_) + 3;
1805 () = (-w $_) + 3;
1806 () = (-x $_) + 3;
1807 ####
1808 # require(foo()) and do(foo())
1809 require (foo());
1810 do (foo());
1811 goto (foo());
1812 CORE::dump (foo());
1813 last (foo());
1814 next (foo());
1815 redo (foo());
1816 ####
1817 # require vstring
1818 require v5.16;
1819 ####
1820 # [perl #97476] not() *does* follow the llafr
1821 $_ = ($a xor not +($1 || 2) ** 2);
1822 ####
1823 # Precedence conundrums with argument-less function calls
1824 () = (eof) + 1;
1825 () = (return) + 1;
1826 () = (return, 1);
1827 () = warn;
1828 () = warn() + 1;
1829 () = setpgrp() + 1;
1830 ####
1831 # loopexes have assignment prec
1832 () = (CORE::dump a) | 'b';
1833 () = (goto a) | 'b';
1834 () = (last a) | 'b';
1835 () = (next a) | 'b';
1836 () = (redo a) | 'b';
1837 ####
1838 # [perl #63558] open local(*FH)
1839 open local *FH;
1840 pipe local *FH, local *FH;
1841 ####
1842 # [perl #91416] open "string"
1843 open 'open';
1844 open '####';
1845 open '^A';
1846 open "\ca";
1847 >>>>
1848 open *open;
1849 open '####';
1850 open '^A';
1851 open *^A;
1852 ####
1853 # "string"->[] ->{}
1854 no strict 'vars';
1855 () = 'open'->[0]; #aelemfast
1856 () = '####'->[0];
1857 () = '^A'->[0];
1858 () = "\ca"->[0];
1859 () = 'a::]b'->[0];
1860 () = 'open'->[$_]; #aelem
1861 () = '####'->[$_];
1862 () = '^A'->[$_];
1863 () = "\ca"->[$_];
1864 () = 'a::]b'->[$_];
1865 () = 'open'->{0}; #helem
1866 () = '####'->{0};
1867 () = '^A'->{0};
1868 () = "\ca"->{0};
1869 () = 'a::]b'->{0};
1870 >>>>
1871 no strict 'vars';
1872 () = $open[0];
1873 () = '####'->[0];
1874 () = '^A'->[0];
1875 () = $^A[0];
1876 () = 'a::]b'->[0];
1877 () = $open[$_];
1878 () = '####'->[$_];
1879 () = '^A'->[$_];
1880 () = $^A[$_];
1881 () = 'a::]b'->[$_];
1882 () = $open{'0'};
1883 () = '####'->{'0'};
1884 () = '^A'->{'0'};
1885 () = $^A{'0'};
1886 () = 'a::]b'->{'0'};
1887 ####
1888 # [perl #74740] -(f()) vs -f()
1889 $_ = -(f());
1890 ####
1891 # require <binop>
1892 require 'a' . $1;
1893 ####
1894 #[perl #30504] foreach-my postfix/prefix difference
1895 $_ = 'foo' foreach my ($foo1, $bar1, $baz1);
1896 foreach (my ($foo2, $bar2, $baz2)) { $_ = 'foo' }
1897 foreach my $i (my ($foo3, $bar3, $baz3)) { $i = 'foo' }
1898 >>>>
1899 $_ = 'foo' foreach (my($foo1, $bar1, $baz1));
1900 foreach $_ (my($foo2, $bar2, $baz2)) {
1901     $_ = 'foo';
1902 }
1903 foreach my $i (my($foo3, $bar3, $baz3)) {
1904     $i = 'foo';
1905 }
1906 ####
1907 #[perl #108224] foreach with continue block
1908 foreach (1 .. 3) { print } continue { print "\n" }
1909 foreach (1 .. 3) { } continue { }
1910 foreach my $i (1 .. 3) { print $i } continue { print "\n" }
1911 foreach my $i (1 .. 3) { } continue { }
1912 >>>>
1913 foreach $_ (1 .. 3) {
1914     print $_;
1915 }
1916 continue {
1917     print "\n";
1918 }
1919 foreach $_ (1 .. 3) {
1920     ();
1921 }
1922 continue {
1923     ();
1924 }
1925 foreach my $i (1 .. 3) {
1926     print $i;
1927 }
1928 continue {
1929     print "\n";
1930 }
1931 foreach my $i (1 .. 3) {
1932     ();
1933 }
1934 continue {
1935     ();
1936 }
1937 ####
1938 # file handles
1939 no strict;
1940 my $mfh;
1941 open F;
1942 open *F;
1943 open $fh;
1944 open $mfh;
1945 open 'a+b';
1946 select *F;
1947 select F;
1948 select $f;
1949 select $mfh;
1950 select 'a+b';
1951 ####
1952 # 'my' works with padrange op
1953 my($z, @z);
1954 my $m1;
1955 $m1 = 1;
1956 $z = $m1;
1957 my $m2 = 2;
1958 my($m3, $m4);
1959 ($m3, $m4) = (1, 2);
1960 @z = ($m3, $m4);
1961 my($m5, $m6) = (1, 2);
1962 my($m7, undef, $m8) = (1, 2, 3);
1963 @z = ($m7, undef, $m8);
1964 ($m7, undef, $m8) = (1, 2, 3);
1965 ####
1966 # 'our/local' works with padrange op
1967 our($z, @z);
1968 our $o1;
1969 no strict;
1970 local $o11;
1971 $o1 = 1;
1972 local $o1 = 1;
1973 $z = $o1;
1974 $z = local $o1;
1975 our $o2 = 2;
1976 our($o3, $o4);
1977 ($o3, $o4) = (1, 2);
1978 local($o3, $o4) = (1, 2);
1979 @z = ($o3, $o4);
1980 @z = local($o3, $o4);
1981 our($o5, $o6) = (1, 2);
1982 our($o7, undef, $o8) = (1, 2, 3);
1983 @z = ($o7, undef, $o8);
1984 @z = local($o7, undef, $o8);
1985 ($o7, undef, $o8) = (1, 2, 3);
1986 local($o7, undef, $o8) = (1, 2, 3);
1987 ####
1988 # 'state' works with padrange op
1989 # CONTEXT no strict; use feature 'state';
1990 state($z, @z);
1991 state $s1;
1992 $s1 = 1;
1993 $z = $s1;
1994 state $s2 = 2;
1995 state($s3, $s4);
1996 ($s3, $s4) = (1, 2);
1997 @z = ($s3, $s4);
1998 # assignment of state lists isn't implemented yet
1999 #state($s5, $s6) = (1, 2);
2000 #state($s7, undef, $s8) = (1, 2, 3);
2001 #@z = ($s7, undef, $s8);
2002 ($s7, undef, $s8) = (1, 2, 3);
2003 ####
2004 # anon arrays with padrange
2005 my($a, $b);
2006 my $c = [$a, $b];
2007 my $d = {$a, $b};
2008 ####
2009 # slices with padrange
2010 my($a, $b);
2011 my(@x, %y);
2012 @x = @x[$a, $b];
2013 @x = @y{$a, $b};
2014 ####
2015 # binops with padrange
2016 my($a, $b, $c);
2017 $c = $a cmp $b;
2018 $c = $a + $b;
2019 $a += $b;
2020 $c = $a - $b;
2021 $a -= $b;
2022 $c = my $a1 cmp $b;
2023 $c = my $a2 + $b;
2024 $a += my $b1;
2025 $c = my $a3 - $b;
2026 $a -= my $b2;
2027 ####
2028 # 'x' with padrange
2029 my($a, $b, $c, $d, @e);
2030 $c = $a x $b;
2031 $a x= $b;
2032 @e = ($a) x $d;
2033 @e = ($a, $b) x $d;
2034 @e = ($a, $b, $c) x $d;
2035 @e = ($a, 1) x $d;
2036 ####
2037 # @_ with padrange
2038 my($a, $b, $c) = @_;
2039 ####
2040 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
2041 # lexical subroutine
2042 # CONTEXT use feature 'lexical_subs';
2043 no warnings "experimental::lexical_subs";
2044 my sub f {}
2045 print f();
2046 >>>>
2047 BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x55\x55"}
2048 my sub f {
2049     
2050 }
2051 print f();
2052 ####
2053 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
2054 # lexical "state" subroutine
2055 # CONTEXT use feature 'state', 'lexical_subs';
2056 no warnings 'experimental::lexical_subs';
2057 state sub f {}
2058 print f();
2059 >>>>
2060 BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x55\x55"}
2061 state sub f {
2062     
2063 }
2064 print f();
2065 ####
2066 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
2067 # lexical subroutine scoping
2068 # CONTEXT use feature 'lexical_subs'; no warnings 'experimental::lexical_subs';
2069 {
2070   {
2071     my sub a { die; }
2072     {
2073       foo();
2074       my sub b;
2075       b ;
2076       main::b();
2077       &main::b;
2078       &main::b();
2079       my $b = \&main::b;
2080       sub b { $b; }
2081     }
2082   }
2083   b();
2084 }
2085 ####
2086 # self-referential lexical subroutine
2087 # CONTEXT use feature 'lexical_subs', 'state'; no warnings 'experimental::lexical_subs';
2088 ();
2089 state sub sb2;
2090 sub sb2 {
2091     sb2 ;
2092 }
2093 ####
2094 # lexical subroutine with outer declaration and inner definition
2095 # CONTEXT use feature 'lexical_subs'; no warnings 'experimental::lexical_subs';
2096 ();
2097 my sub f;
2098 my sub g {
2099     ();
2100     sub f { }
2101 }
2102 ####
2103 # TODO only partially fixed
2104 # lexical state subroutine with outer declaration and inner definition
2105 # CONTEXT use feature 'lexical_subs', 'state'; no warnings 'experimental::lexical_subs';
2106 ();
2107 state sub sb4;
2108 state sub a {
2109     ();
2110     sub sb4 { }
2111 }
2112 state sub sb5;
2113 sub {
2114     ();
2115     sub sb5 { }
2116 } ;
2117 ####
2118 # Elements of %# should not be confused with $#{ array }
2119 () = ${#}{'foo'};
2120 ####
2121 # $; [perl #123357]
2122 $_ = $;;
2123 do {
2124     $;
2125 };
2126 ####
2127 # Ampersand calls and scalar context
2128 # OPTIONS -P
2129 package prototest;
2130 sub foo($$);
2131 foo(bar(),baz());
2132 >>>>
2133 package prototest;
2134 &foo(scalar bar(), scalar baz());
2135 ####
2136 # coderef2text and prototyped sub calls [perl #123435]
2137 is 'foo', 'oo';
2138 ####
2139 # prototypes with unary precedence
2140 package prototest;
2141 sub dollar($) {}
2142 sub optdollar(;$) {}
2143 sub optoptdollar(;;$) {}
2144 sub splat(*) {}
2145 sub optsplat(;*) {}
2146 sub optoptsplat(;;*) {}
2147 sub bar(_) {}
2148 sub optbar(;_) {}
2149 sub optoptbar(;;_) {}
2150 sub plus(+) {}
2151 sub optplus(;+) {}
2152 sub optoptplus(;;+) {}
2153 sub wack(\$) {}
2154 sub optwack(;\$) {}
2155 sub optoptwack(;;\$) {}
2156 sub wackbrack(\[$]) {}
2157 sub optwackbrack(;\[$]) {}
2158 sub optoptwackbrack(;;\[$]) {}
2159 dollar($a < $b);
2160 optdollar($a < $b);
2161 optoptdollar($a < $b);
2162 splat($a < $b);     # Some of these deparse with â€˜&’; if that changes, just
2163 optsplat($a < $b);  # change the tests.
2164 optoptsplat($a < $b);
2165 bar($a < $b);
2166 optbar($a < $b);
2167 optoptbar($a < $b);
2168 plus($a < $b);
2169 optplus($a < $b);
2170 optoptplus($a < $b);
2171 wack($a = $b);
2172 optwack($a = $b);
2173 optoptwack($a = $b);
2174 wackbrack($a = $b);
2175 optwackbrack($a = $b);
2176 optoptwackbrack($a = $b);
2177 >>>>
2178 package prototest;
2179 dollar($a < $b);
2180 optdollar($a < $b);
2181 optoptdollar($a < $b);
2182 &splat($a < $b);
2183 &optsplat($a < $b);
2184 &optoptsplat($a < $b);
2185 bar($a < $b);
2186 optbar($a < $b);
2187 optoptbar($a < $b);
2188 &plus($a < $b);
2189 &optplus($a < $b);
2190 &optoptplus($a < $b);
2191 &wack(\($a = $b));
2192 &optwack(\($a = $b));
2193 &optoptwack(\($a = $b));
2194 &wackbrack(\($a = $b));
2195 &optwackbrack(\($a = $b));
2196 &optoptwackbrack(\($a = $b));
2197 ####
2198 # ensure aelemfast works in the range -128..127 and that there's no
2199 # funky edge cases
2200 my $x;
2201 no strict 'vars';
2202 $x = $a[-256] + $a[-255] + $a[-129] + $a[-128] + $a[-127] + $a[-1] + $a[0];
2203 $x = $a[1] + $a[126] + $a[127] + $a[128] + $a[255] + $a[256];
2204 my @b;
2205 $x = $b[-256] + $b[-255] + $b[-129] + $b[-128] + $b[-127] + $b[-1] + $b[0];
2206 $x = $b[1] + $b[126] + $b[127] + $b[128] + $b[255] + $b[256];
2207 ####
2208 # 'm' must be preserved in m??
2209 m??;
2210 ####
2211 # \(@array) and \(..., (@array), ...)
2212 my(@array, %hash, @a, @b, %c, %d);
2213 () = \(@array);
2214 () = \(%hash);
2215 () = \(@a, (@b), (%c), %d);
2216 () = \(@Foo::array);
2217 () = \(%Foo::hash);
2218 () = \(@Foo::a, (@Foo::b), (%Foo::c), %Foo::d);
2219 ####
2220 # subs synonymous with keywords
2221 main::our();
2222 main::pop();
2223 state();
2224 use feature 'state';
2225 main::state();
2226 ####
2227 # lvalue references
2228 # CONTEXT use feature "state", 'refaliasing', 'lexical_subs'; no warnings 'experimental';
2229 our $x;
2230 \$x = \$x;
2231 my $m;
2232 \$m = \$x;
2233 \my $n = \$x;
2234 (\$x) = @_;
2235 \($x) = @_;
2236 \($m) = @_;
2237 (\$m) = @_;
2238 \my($p) = @_;
2239 (\my $r) = @_;
2240 \($x, my $a) = @{[\$x, \$x]};
2241 (\$x, \my $b) = @{[\$x, \$x]};
2242 \local $x = \3;
2243 \local($x) = \3;
2244 \state $c = \3;
2245 \state($d) = \3;
2246 \our $e = \3;
2247 \our($f) = \3;
2248 \$_[0] = foo();
2249 \($_[1]) = foo();
2250 my @a;
2251 \$a[0] = foo();
2252 \($a[1]) = foo();
2253 \local($a[1]) = foo();
2254 \@a[0,1] = foo();
2255 \(@a[2,3]) = foo();
2256 \local @a[0,1] = (\$a)x2;
2257 \$_{a} = foo();
2258 \($_{b}) = foo();
2259 my %h;
2260 \$h{a} = foo();
2261 \($h{b}) = foo();
2262 \local $h{a} = \$x;
2263 \local($h{b}) = \$x;
2264 \@h{'a','b'} = foo();
2265 \(@h{2,3}) = foo();
2266 \local @h{'a','b'} = (\$x)x2;
2267 \@_ = foo();
2268 \@a = foo();
2269 (\@_) = foo();
2270 (\@a) = foo();
2271 \my @c = foo();
2272 (\my @d) = foo();
2273 \(@_) = foo();
2274 \(@a) = foo();
2275 \my(@g) = foo();
2276 \local @_ = \@_;
2277 (\local @_) = \@_;
2278 \state @e = [1..3];
2279 \state(@f) = \3;
2280 \our @i = [1..3];
2281 \our(@h) = \3;
2282 \%_ = foo();
2283 \%h = foo();
2284 (\%_) = foo();
2285 (\%h) = foo();
2286 \my %c = foo();
2287 (\my %d) = foo();
2288 \local %_ = \%h;
2289 (\local %_) = \%h;
2290 \state %y = {1,2};
2291 \our %z = {1,2};
2292 (\our %zz) = {1,2};
2293 \&a = foo();
2294 (\&a) = foo();
2295 \(&a) = foo();
2296 {
2297   my sub a;
2298   \&a = foo();
2299   (\&a) = foo();
2300   \(&a) = foo();
2301 }
2302 (\$_, $_) = \(1, 2);
2303 $_ == 3 ? \$_ : $_ = \3;
2304 $_ == 3 ? \$_ : \$x = \3;
2305 \($_ == 3 ? $_ : $x) = \3;
2306 for \my $topic (\$1, \$2) {
2307     die;
2308 }
2309 for \state $topic (\$1, \$2) {
2310     die;
2311 }
2312 for \our $topic (\$1, \$2) {
2313     die;
2314 }
2315 for \$_ (\$1, \$2) {
2316     die;
2317 }
2318 for \my @a ([1,2], [3,4]) {
2319     die;
2320 }
2321 for \state @a ([1,2], [3,4]) {
2322     die;
2323 }
2324 for \our @a ([1,2], [3,4]) {
2325     die;
2326 }
2327 for \@_ ([1,2], [3,4]) {
2328     die;
2329 }
2330 for \my %a ({5,6}, {7,8}) {
2331     die;
2332 }
2333 for \our %a ({5,6}, {7,8}) {
2334     die;
2335 }
2336 for \state %a ({5,6}, {7,8}) {
2337     die;
2338 }
2339 for \%_ ({5,6}, {7,8}) {
2340     die;
2341 }
2342 {
2343     my sub a;
2344     for \&a (sub { 9; }, sub { 10; }) {
2345         die;
2346     }
2347 }
2348 for \&a (sub { 9; }, sub { 10; }) {
2349     die;
2350 }
2351 >>>>
2352 our $x;
2353 \$x = \$x;
2354 my $m;
2355 \$m = \$x;
2356 \my $n = \$x;
2357 (\$x) = @_;
2358 (\$x) = @_;
2359 (\$m) = @_;
2360 (\$m) = @_;
2361 (\my $p) = @_;
2362 (\my $r) = @_;
2363 (\$x, \my $a) = @{[\$x, \$x];};
2364 (\$x, \my $b) = @{[\$x, \$x];};
2365 \local $x = \3;
2366 (\local $x) = \3;
2367 \state $c = \3;
2368 (\state $d) = \3;
2369 \our $e = \3;
2370 (\our $f) = \3;
2371 \$_[0] = foo();
2372 (\$_[1]) = foo();
2373 my @a;
2374 \$a[0] = foo();
2375 (\$a[1]) = foo();
2376 (\local $a[1]) = foo();
2377 (\@a[0, 1]) = foo();
2378 (\@a[2, 3]) = foo();
2379 (\local @a[0, 1]) = (\$a) x 2;
2380 \$_{'a'} = foo();
2381 (\$_{'b'}) = foo();
2382 my %h;
2383 \$h{'a'} = foo();
2384 (\$h{'b'}) = foo();
2385 \local $h{'a'} = \$x;
2386 (\local $h{'b'}) = \$x;
2387 (\@h{'a', 'b'}) = foo();
2388 (\@h{2, 3}) = foo();
2389 (\local @h{'a', 'b'}) = (\$x) x 2;
2390 \@_ = foo();
2391 \@a = foo();
2392 (\@_) = foo();
2393 (\@a) = foo();
2394 \my @c = foo();
2395 (\my @d) = foo();
2396 (\(@_)) = foo();
2397 (\(@a)) = foo();
2398 (\(my @g)) = foo();
2399 \local @_ = \@_;
2400 (\local @_) = \@_;
2401 \state @e = [1..3];
2402 (\(state @f)) = \3;
2403 \our @i = [1..3];
2404 (\(our @h)) = \3;
2405 \%_ = foo();
2406 \%h = foo();
2407 (\%_) = foo();
2408 (\%h) = foo();
2409 \my %c = foo();
2410 (\my %d) = foo();
2411 \local %_ = \%h;
2412 (\local %_) = \%h;
2413 \state %y = {1, 2};
2414 \our %z = {1, 2};
2415 (\our %zz) = {1, 2};
2416 \&a = foo();
2417 (\&a) = foo();
2418 (\&a) = foo();
2419 {
2420   my sub a;
2421   \&a = foo();
2422   (\&a) = foo();
2423   (\&a) = foo();
2424 }
2425 (\$_, $_) = \(1, 2);
2426 $_ == 3 ? \$_ : $_ = \3;
2427 $_ == 3 ? \$_ : \$x = \3;
2428 ($_ == 3 ? \$_ : \$x) = \3;
2429 foreach \my $topic (\$1, \$2) {
2430     die;
2431 }
2432 foreach \state $topic (\$1, \$2) {
2433     die;
2434 }
2435 foreach \our $topic (\$1, \$2) {
2436     die;
2437 }
2438 foreach \$_ (\$1, \$2) {
2439     die;
2440 }
2441 foreach \my @a ([1, 2], [3, 4]) {
2442     die;
2443 }
2444 foreach \state @a ([1, 2], [3, 4]) {
2445     die;
2446 }
2447 foreach \our @a ([1, 2], [3, 4]) {
2448     die;
2449 }
2450 foreach \@_ ([1, 2], [3, 4]) {
2451     die;
2452 }
2453 foreach \my %a ({5, 6}, {7, 8}) {
2454     die;
2455 }
2456 foreach \our %a ({5, 6}, {7, 8}) {
2457     die;
2458 }
2459 foreach \state %a ({5, 6}, {7, 8}) {
2460     die;
2461 }
2462 foreach \%_ ({5, 6}, {7, 8}) {
2463     die;
2464 }
2465 {
2466     my sub a;
2467     foreach \&a (sub { 9; } , sub { 10; } ) {
2468         die;
2469     }
2470 }
2471 foreach \&a (sub { 9; } , sub { 10; } ) {
2472     die;
2473 }
2474 ####
2475 # join $foo, pos
2476 my $foo;
2477 $_ = join $foo, pos
2478 >>>>
2479 my $foo;
2480 $_ = join('???', pos $_);
2481 ####
2482 # exists $a[0]
2483 our @a;
2484 exists $a[0];
2485 ####
2486 # my @a; exists $a[0]
2487 my @a;
2488 exists $a[0];
2489 ####
2490 # delete $a[0]
2491 our @a;
2492 delete $a[0];
2493 ####
2494 # my @a; delete $a[0]
2495 my @a;
2496 delete $a[0];
2497 ####
2498 # $_[0][$_[1]]
2499 $_[0][$_[1]];
2500 ####
2501 # f($a[0]);
2502 my @a;
2503 f($a[0]);
2504 ####
2505 #qr/\Q$h{'key'}\E/;
2506 my %h;
2507 qr/\Q$h{'key'}\E/;
2508 ####
2509 # my $x = "$h{foo}";
2510 my %h;
2511 my $x = "$h{'foo'}";
2512 ####
2513 # weird constant hash key
2514 my %h;
2515 my $x = $h{"\000\t\x{100}"};
2516 ####
2517 # multideref and packages
2518 package foo;
2519 my(%bar) = ('a', 'b');
2520 our(@bar) = (1, 2);
2521 $bar{'k'} = $bar[200];
2522 $main::bar{'k'} = $main::bar[200];
2523 $foo::bar{'k'} = $foo::bar[200];
2524 package foo2;
2525 $bar{'k'} = $bar[200];
2526 $main::bar{'k'} = $main::bar[200];
2527 $foo::bar{'k'} = $foo::bar[200];
2528 >>>>
2529 package foo;
2530 my(%bar) = ('a', 'b');
2531 our(@bar) = (1, 2);
2532 $bar{'k'} = $bar[200];
2533 $main::bar{'k'} = $main::bar[200];
2534 $foo::bar{'k'} = $bar[200];
2535 package foo2;
2536 $bar{'k'} = $foo::bar[200];
2537 $main::bar{'k'} = $main::bar[200];
2538 $foo::bar{'k'} = $foo::bar[200];
2539 ####
2540 # multideref and local
2541 my %h;
2542 local $h{'foo'}[0] = 1;
2543 ####
2544 # multideref and exists
2545 my(%h, $i);
2546 my $e = exists $h{'foo'}[$i];
2547 ####
2548 # multideref and delete
2549 my(%h, $i);
2550 my $e = delete $h{'foo'}[$i];
2551 ####
2552 # multideref with leading expression
2553 my $r;
2554 my $x = +($r // [])->{'foo'}[0];
2555 ####
2556 # multideref with complex middle index
2557 my(%h, $i, $j, $k);
2558 my $x = $h{'foo'}[$i + $j]{$k};
2559 ####
2560 # multideref with trailing non-simple index that initially looks simple
2561 # (i.e. the constant "3")
2562 my($r, $i, $j, $k);
2563 my $x = +($r || {})->{'foo'}[$i + $j]{3 + $k};
2564 ####
2565 # chdir
2566 chdir 'file';
2567 chdir FH;
2568 chdir;
2569 ####
2570 # 5.22 bitops
2571 # CONTEXT use feature "bitwise"; no warnings "experimental::bitwise";
2572 $_ = $_ | $_;
2573 $_ = $_ & $_;
2574 $_ = $_ ^ $_;
2575 $_ = ~$_;
2576 $_ = $_ |. $_;
2577 $_ = $_ &. $_;
2578 $_ = $_ ^. $_;
2579 $_ = ~.$_;
2580 $_ |= $_;
2581 $_ &= $_;
2582 $_ ^= $_;
2583 $_ |.= $_;
2584 $_ &.= $_;
2585 $_ ^.= $_;
2586 ####
2587 ####
2588 # Should really use 'no warnings "experimental::signatures"',
2589 # but it doesn't yet deparse correctly.
2590 # anon subs used because this test framework doesn't deparse named subs
2591 # in the DATA code snippets.
2592 #
2593 # general signature
2594 no warnings;
2595 use feature 'signatures';
2596 my $x;
2597 sub ($a, $, $b = $glo::bal, $c = $a, $d = 'foo', $e = -37, $f = 0, $g = 1, $h = undef, $i = $a + 1, $j = /foo/, @) {
2598     $x++;
2599 }
2600 ;
2601 $x++;
2602 ####
2603 # Signature and prototype
2604 no warnings;
2605 use feature 'signatures';
2606 my $x;
2607 my $f = sub : prototype($$) ($a, $b) {
2608     $x++;
2609 }
2610 ;
2611 $x++;
2612 ####
2613 # Signature and prototype and attrs
2614 no warnings;
2615 use feature 'signatures';
2616 my $x;
2617 my $f = sub : prototype($$) lvalue ($a, $b) {
2618     $x++;
2619 }
2620 ;
2621 $x++;
2622 ####
2623 # Signature and attrs
2624 no warnings;
2625 use feature 'signatures';
2626 my $x;
2627 my $f = sub : lvalue method ($a, $b) {
2628     $x++;
2629 }
2630 ;
2631 $x++;
2632 ####
2633 # named array slurp, null body
2634 no warnings;
2635 use feature 'signatures';
2636 sub (@a) {
2637     ;
2638 }
2639 ;
2640 ####
2641 # named hash slurp
2642 no warnings;
2643 use feature 'signatures';
2644 sub ($key, %h) {
2645     $h{$key};
2646 }
2647 ;
2648 ####
2649 # anon hash slurp
2650 no warnings;
2651 use feature 'signatures';
2652 sub ($a, %) {
2653     $a;
2654 }
2655 ;
2656 ####
2657 # parenthesised default arg
2658 no warnings;
2659 use feature 'signatures';
2660 sub ($a, $b = (/foo/), $c = 1) {
2661     $a + $b + $c;
2662 }
2663 ;
2664 ####
2665 # parenthesised default arg with TARGMY
2666 no warnings;
2667 use feature 'signatures';
2668 sub ($a, $b = ($a + 1), $c = 1) {
2669     $a + $b + $c;
2670 }
2671 ;
2672 ####
2673 # empty default
2674 no warnings;
2675 use feature 'signatures';
2676 sub ($a, $=) {
2677     $a;
2678 }
2679 ;
2680 ####
2681 # padrange op within pattern code blocks
2682 /(?{ my($x, $y) = (); })/;
2683 my $a;
2684 /$a(?{ my($x, $y) = (); })/;
2685 my $r1 = qr/(?{ my($x, $y) = (); })/;
2686 my $r2 = qr/$a(?{ my($x, $y) = (); })/;
2687 ####
2688 # don't remove pattern whitespace escapes
2689 /a\ b/;
2690 /a\ b/x;
2691 /a\     b/;
2692 /a\     b/x;
2693 ####
2694 # my attributes
2695 my $s1 :foo(f1, f2) bar(b1, b2);
2696 my @a1 :foo(f1, f2) bar(b1, b2);
2697 my %h1 :foo(f1, f2) bar(b1, b2);
2698 my($s2, @a2, %h2) :foo(f1, f2) bar(b1, b2);
2699 ####
2700 # my class attributes
2701 package Foo::Bar;
2702 my Foo::Bar $s1 :foo(f1, f2) bar(b1, b2);
2703 my Foo::Bar @a1 :foo(f1, f2) bar(b1, b2);
2704 my Foo::Bar %h1 :foo(f1, f2) bar(b1, b2);
2705 my Foo::Bar ($s2, @a2, %h2) :foo(f1, f2) bar(b1, b2);
2706 package main;
2707 my Foo::Bar $s3 :foo(f1, f2) bar(b1, b2);
2708 my Foo::Bar @a3 :foo(f1, f2) bar(b1, b2);
2709 my Foo::Bar %h3 :foo(f1, f2) bar(b1, b2);
2710 my Foo::Bar ($s4, @a4, %h4) :foo(f1, f2) bar(b1, b2);
2711 ####
2712 # avoid false positives in my $x :attribute
2713 'attributes'->import('main', \my $x1, 'foo(bar)'), my $y1;
2714 'attributes'->import('Fooo', \my $x2, 'foo(bar)'), my $y2;
2715 ####
2716 # hash slices and hash key/value slices
2717 my(@a, %h);
2718 our(@oa, %oh);
2719 @a = @h{'foo', 'bar'};
2720 @a = %h{'foo', 'bar'};
2721 @a = delete @h{'foo', 'bar'};
2722 @a = delete %h{'foo', 'bar'};
2723 @oa = @oh{'foo', 'bar'};
2724 @oa = %oh{'foo', 'bar'};
2725 @oa = delete @oh{'foo', 'bar'};
2726 @oa = delete %oh{'foo', 'bar'};
2727 ####
2728 # keys optimised away in void and scalar context
2729 no warnings;
2730 ;
2731 our %h1;
2732 my($x, %h2);
2733 %h1;
2734 keys %h1;
2735 $x = %h1;
2736 $x = keys %h1;
2737 %h2;
2738 keys %h2;
2739 $x = %h2;
2740 $x = keys %h2;
2741 ####
2742 # eq,const optimised away for (index() == -1)
2743 my($a, $b);
2744 our $c;
2745 $c = index($a, $b) == 2;
2746 $c = rindex($a, $b) == 2;
2747 $c = index($a, $b) == -1;
2748 $c = rindex($a, $b) == -1;
2749 $c = index($a, $b) != -1;
2750 $c = rindex($a, $b) != -1;
2751 $c = (index($a, $b) == -1);
2752 $c = (rindex($a, $b) == -1);
2753 $c = (index($a, $b) != -1);
2754 $c = (rindex($a, $b) != -1);
2755 ####
2756 # eq,const,sassign,madmy optimised away for (index() == -1)
2757 my($a, $b);
2758 my $c;
2759 $c = index($a, $b) == 2;
2760 $c = rindex($a, $b) == 2;
2761 $c = index($a, $b) == -1;
2762 $c = rindex($a, $b) == -1;
2763 $c = index($a, $b) != -1;
2764 $c = rindex($a, $b) != -1;
2765 $c = (index($a, $b) == -1);
2766 $c = (rindex($a, $b) == -1);
2767 $c = (index($a, $b) != -1);
2768 $c = (rindex($a, $b) != -1);
2769 ####
2770 # plain multiconcat
2771 my($a, $b, $c, $d, @a);
2772 $d = length $a . $b . $c;
2773 $d = length($a) . $b . $c;
2774 print '' . $a;
2775 push @a, ($a . '') * $b;
2776 unshift @a, "$a" * ($b . '');
2777 print $a . 'x' . $b . $c;
2778 print $a . 'x' . $b . $c, $d;
2779 print $b . $c . ($a . $b);
2780 print $b . $c . ($a . $b);
2781 print $b . $c . @a;
2782 print $a . "\x{100}";
2783 ####
2784 # double-quoted multiconcat
2785 my($a, $b, $c, $d, @a);
2786 print "${a}x\x{100}$b$c";
2787 print "$a\Q$b\E$c\Ua$a\E\Lb$b\uc$c\E$a${b}c$c";
2788 print "A=$a[length 'b' . $c . 'd'] b=$b";
2789 print "A=@a B=$b";
2790 print "\x{101}$a\x{100}";
2791 $a = qr/\Q
2792 $b $c
2793 \x80
2794 \x{100}
2795 \E$c
2796 /;
2797 ####
2798 # sprintf multiconcat
2799 my($a, $b, $c, $d, @a);
2800 print sprintf("%s%s%%%sx%s\x{100}%s", $a, $b, $c, scalar @a, $d);
2801 ####
2802 # multiconcat with lexical assign
2803 my($a, $b, $c, $d, $e, @a);
2804 $d = 'foo' . $a;
2805 $d = "foo$a";
2806 $d = $a . '';
2807 $d = 'foo' . $a . 'bar';
2808 $d = $a . $b;
2809 $d = $a . $b . $c;
2810 $d = $a . $b . $c . @a;
2811 $e = ($d = $a . $b . $c);
2812 $d = !$a . $b . $c;
2813 $a = $b . $c . ($a . $b);
2814 $e = f($d = !$a . $b) . $c;
2815 $d = "${a}x\x{100}$b$c";
2816 f($d = !$a . $b . $c);
2817 ####
2818 # multiconcat with lexical my
2819 my($a, $b, $c, $d, $e, @a);
2820 my $d1 = 'foo' . $a;
2821 my $d2 = "foo$a";
2822 my $d3 = $a . '';
2823 my $d4 = 'foo' . $a . 'bar';
2824 my $d5 = $a . $b;
2825 my $d6 = $a . $b . $c;
2826 my $e7 = ($d = $a . $b . $c);
2827 my $d8 = !$a . $b . $c;
2828 my $d9 = $b . $c . ($a . $b);
2829 my $da = f($d = !$a . $b) . $c;
2830 my $dc = "${a}x\x{100}$b$c";
2831 f(my $db = !$a . $b . $c);
2832 my $dd = $a . $b . $c . @a;
2833 ####
2834 # multiconcat with lexical append
2835 my($a, $b, $c, $d, $e, @a);
2836 $d .= '';
2837 $d .= $a;
2838 $d .= "$a";
2839 $d .= 'foo' . $a;
2840 $d .= "foo$a";
2841 $d .= $a . '';
2842 $d .= 'foo' . $a . 'bar';
2843 $d .= $a . $b;
2844 $d .= $a . $b . $c;
2845 $d .= $a . $b . @a;
2846 $e .= ($d = $a . $b . $c);
2847 $d .= !$a . $b . $c;
2848 $a .= $b . $c . ($a . $b);
2849 $e .= f($d .= !$a . $b) . $c;
2850 f($d .= !$a . $b . $c);
2851 $d .= "${a}x\x{100}$b$c";
2852 ####
2853 # multiconcat with expression assign
2854 my($a, $b, $c, @a);
2855 our($d, $e);
2856 $d = 'foo' . $a;
2857 $d = "foo$a";
2858 $d = $a . '';
2859 $d = 'foo' . $a . 'bar';
2860 $d = $a . $b;
2861 $d = $a . $b . $c;
2862 $d = $a . $b . @a;
2863 $e = ($d = $a . $b . $c);
2864 $a["-$b-"] = !$a . $b . $c;
2865 $a[$b]{$c}{$d ? $a : $b . $c} = !$a . $b . $c;
2866 $a = $b . $c . ($a . $b);
2867 $e = f($d = !$a . $b) . $c;
2868 $d = "${a}x\x{100}$b$c";
2869 f($d = !$a . $b . $c);
2870 ####
2871 # multiconcat with expression concat
2872 my($a, $b, $c, @a);
2873 our($d, $e);
2874 $d .= 'foo' . $a;
2875 $d .= "foo$a";
2876 $d .= $a . '';
2877 $d .= 'foo' . $a . 'bar';
2878 $d .= $a . $b;
2879 $d .= $a . $b . $c;
2880 $d .= $a . $b . @a;
2881 $e .= ($d .= $a . $b . $c);
2882 $a["-$b-"] .= !$a . $b . $c;
2883 $a[$b]{$c}{$d ? $a : $b . $c} .= !$a . $b . $c;
2884 $a .= $b . $c . ($a . $b);
2885 $e .= f($d .= !$a . $b) . $c;
2886 $d .= "${a}x\x{100}$b$c";
2887 f($d .= !$a . $b . $c);
2888 ####
2889 # multiconcat with CORE::sprintf
2890 # CONTEXT sub sprintf {}
2891 my($a, $b);
2892 my $x = CORE::sprintf('%s%s', $a, $b);
2893 ####
2894 # multiconcat with backticks
2895 my($a, $b);
2896 our $x;
2897 $x = `$a-$b`;
2898 ####
2899 # multiconcat within qr//
2900 my($r, $a, $b);
2901 $r = qr/abc\Q$a-$b\Exyz/;
2902 ####
2903 # tr with unprintable characters
2904 my $str;
2905 $str = 'foo';
2906 $str =~ tr/\cA//;
2907 ####
2908 # CORE::foo special case in bareword parsing
2909 print $CORE::foo, $CORE::foo::bar;
2910 print @CORE::foo, @CORE::foo::bar;
2911 print %CORE::foo, %CORE::foo::bar;
2912 print $CORE::foo{'a'}, $CORE::foo::bar{'a'};
2913 print &CORE::foo, &CORE::foo::bar;
2914 print &CORE::foo(), &CORE::foo::bar();
2915 print \&CORE::foo, \&CORE::foo::bar;
2916 print *CORE::foo, *CORE::foo::bar;
2917 print stat CORE::foo::, stat CORE::foo::bar;
2918 print CORE::foo:: 1;
2919 print CORE::foo::bar 2;
2920 ####
2921 # trailing colons on glob names
2922 no strict 'vars';
2923 $Foo::::baz = 1;
2924 print $foo, $foo::, $foo::::;
2925 print @foo, @foo::, @foo::::;
2926 print %foo, %foo::, %foo::::;
2927 print $foo{'a'}, $foo::{'a'}, $foo::::{'a'};
2928 print &foo, &foo::, &foo::::;
2929 print &foo(), &foo::(), &foo::::();
2930 print \&foo, \&foo::, \&foo::::;
2931 print *foo, *foo::, *foo::::;
2932 print stat Foo, stat Foo::::;
2933 print Foo 1;
2934 print Foo:::: 2;
2935 ####
2936 # trailing colons mixed with CORE
2937 no strict 'vars';
2938 print $CORE, $CORE::, $CORE::::;
2939 print @CORE, @CORE::, @CORE::::;
2940 print %CORE, %CORE::, %CORE::::;
2941 print $CORE{'a'}, $CORE::{'a'}, $CORE::::{'a'};
2942 print &CORE, &CORE::, &CORE::::;
2943 print &CORE(), &CORE::(), &CORE::::();
2944 print \&CORE, \&CORE::, \&CORE::::;
2945 print *CORE, *CORE::, *CORE::::;
2946 print stat CORE, stat CORE::::;
2947 print CORE 1;
2948 print CORE:::: 2;
2949 print $CORE::foo, $CORE::foo::, $CORE::foo::::;
2950 print @CORE::foo, @CORE::foo::, @CORE::foo::::;
2951 print %CORE::foo, %CORE::foo::, %CORE::foo::::;
2952 print $CORE::foo{'a'}, $CORE::foo::{'a'}, $CORE::foo::::{'a'};
2953 print &CORE::foo, &CORE::foo::, &CORE::foo::::;
2954 print &CORE::foo(), &CORE::foo::(), &CORE::foo::::();
2955 print \&CORE::foo, \&CORE::foo::, \&CORE::foo::::;
2956 print *CORE::foo, *CORE::foo::, *CORE::foo::::;
2957 print stat CORE::foo::, stat CORE::foo::::;
2958 print CORE::foo:: 1;
2959 print CORE::foo:::: 2;
2960 ####
2961 # \&foo
2962 my sub foo {
2963     1;
2964 }
2965 no strict 'vars';
2966 print \&main::foo;
2967 print \&{foo};
2968 print \&bar;
2969 use strict 'vars';
2970 print \&main::foo;
2971 print \&{foo};
2972 print \&main::bar;
2973 ####
2974 # exists(&foo)
2975 my sub foo {
2976     1;
2977 }
2978 no strict 'vars';
2979 print exists &main::foo;
2980 print exists &{foo};
2981 print exists &bar;
2982 use strict 'vars';
2983 print exists &main::foo;
2984 print exists &{foo};
2985 print exists &main::bar;
2986 # precedence of optimised-away 'keys' (OPpPADHV_ISKEYS/OPpRV2HV_ISKEYS)
2987 my($r1, %h1, $res);
2988 our($r2, %h2);
2989 $res = keys %h1;
2990 $res = keys %h2;
2991 $res = keys %$r1;
2992 $res = keys %$r2;
2993 $res = keys(%h1) / 2 - 1;
2994 $res = keys(%h2) / 2 - 1;
2995 $res = keys(%$r1) / 2 - 1;
2996 $res = keys(%$r2) / 2 - 1;
2997 ####
2998 # ditto in presence of sub keys {}
2999 # CONTEXT sub keys {}
3000 no warnings;
3001 my($r1, %h1, $res);
3002 our($r2, %h2);
3003 CORE::keys %h1;
3004 CORE::keys(%h1) / 2;
3005 $res = CORE::keys %h1;
3006 $res = CORE::keys %h2;
3007 $res = CORE::keys %$r1;
3008 $res = CORE::keys %$r2;
3009 $res = CORE::keys(%h1) / 2 - 1;
3010 $res = CORE::keys(%h2) / 2 - 1;
3011 $res = CORE::keys(%$r1) / 2 - 1;
3012 $res = CORE::keys(%$r2) / 2 - 1;
3013 ####
3014 # concat: STACKED: ambiguity between .= and optimised nested
3015 my($a, $b);
3016 $b = $a . $a . $a;
3017 (($a .= $a) .= $a) .= $a;
3018 ####
3019 # multiconcat: $$ within string
3020 my($a, $x);
3021 $x = "${$}abc";
3022 $x = "\$$a";
3023 ####
3024 # single state aggregate assignment
3025 # CONTEXT use feature "state";
3026 state @a = (1, 2, 3);
3027 state %h = ('a', 1, 'b', 2);
3028 ####
3029 # state var with attribute
3030 # CONTEXT use feature "state";
3031 state $x :shared;
3032 state $y :shared = 1;
3033 state @a :shared;
3034 state @b :shared = (1, 2);
3035 state %h :shared;
3036 state %i :shared = ('a', 1, 'b', 2);
3037 ####
3038 # \our @a shouldn't be a list
3039 my $r = \our @a;
3040 my(@l) = \our((@b));
3041 @l = \our(@c, @d);
3042 ####
3043 # postfix $#
3044 our(@b, $s, $l);
3045 $l = (\my @a)->$#*;
3046 (\@b)->$#* = 1;
3047 ++(\my @c)->$#*;
3048 $l = $#a;
3049 $#a = 1;
3050 $l = $#b;
3051 $#b = 1;
3052 my $r;
3053 $l = $r->$#*;
3054 $r->$#* = 1;
3055 $l = $#{@$r;};
3056 $#{$r;} = 1;
3057 $l = $s->$#*;
3058 $s->$#* = 1;
3059 $l = $#{@$s;};
3060 $#{$s;} = 1;
3061 ####
3062 # TODO doesn't preserve backslash
3063 my @a;
3064 my $s = "$a[0]\[1]";