This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deparse: handle \our @a
[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 # TODO [perl #120950] This succeeds when run a 2nd time
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 # ${#} interpolated
1722 # It's a known TODO that warnings are deparsed as bits, not textually.
1723 no warnings;
1724 () = "${#}a";
1725 ####
1726 # [perl #86060] $( $| $) in regexps need braces
1727 /${(}/;
1728 /${|}/;
1729 /${)}/;
1730 /${(}${|}${)}/;
1731 /@{+}@{-}/;
1732 ####
1733 # ()[...]
1734 my(@a) = ()[()];
1735 ####
1736 # sort(foo(bar))
1737 # sort(foo(bar)) is interpreted as sort &foo(bar)
1738 # sort foo(bar) is interpreted as sort foo bar
1739 # parentheses are not optional in this case
1740 print sort(foo('bar'));
1741 >>>>
1742 print sort(foo('bar'));
1743 ####
1744 # substr assignment
1745 substr(my $a, 0, 0) = (foo(), bar());
1746 $a++;
1747 ####
1748 # This following line works around an unfixed bug that we are not trying to 
1749 # test for here:
1750 # CONTEXT BEGIN { $^H{a} = "b"; delete $^H{a} } # make %^H localised
1751 # hint hash
1752 BEGIN { $^H{'foo'} = undef; }
1753 {
1754  BEGIN { $^H{'bar'} = undef; }
1755  {
1756   BEGIN { $^H{'baz'} = undef; }
1757   {
1758    print $_;
1759   }
1760   print $_;
1761  }
1762  print $_;
1763 }
1764 BEGIN { $^H{q[']} = '('; }
1765 print $_;
1766 ####
1767 # This following line works around an unfixed bug that we are not trying to 
1768 # test for here:
1769 # CONTEXT BEGIN { $^H{a} = "b"; delete $^H{a} } # make %^H localised
1770 # hint hash changes that serialise the same way with sort %hh
1771 BEGIN { $^H{'a'} = 'b'; }
1772 {
1773  BEGIN { $^H{'b'} = 'a'; delete $^H{'a'}; }
1774  print $_;
1775 }
1776 print $_;
1777 ####
1778 # [perl #47361] do({}) and do +{} (variants of do-file)
1779 do({});
1780 do +{};
1781 sub foo::do {}
1782 package foo;
1783 CORE::do({});
1784 CORE::do +{};
1785 >>>>
1786 do({});
1787 do({});
1788 package foo;
1789 CORE::do({});
1790 CORE::do({});
1791 ####
1792 # [perl #77096] functions that do not follow the llafr
1793 () = (return 1) + time;
1794 () = (return ($1 + $2) * $3) + time;
1795 () = (return ($a xor $b)) + time;
1796 () = (do 'file') + time;
1797 () = (do ($1 + $2) * $3) + time;
1798 () = (do ($1 xor $2)) + time;
1799 () = (goto 1) + 3;
1800 () = (require 'foo') + 3;
1801 () = (require foo) + 3;
1802 () = (CORE::dump 1) + 3;
1803 () = (last 1) + 3;
1804 () = (next 1) + 3;
1805 () = (redo 1) + 3;
1806 () = (-R $_) + 3;
1807 () = (-W $_) + 3;
1808 () = (-X $_) + 3;
1809 () = (-r $_) + 3;
1810 () = (-w $_) + 3;
1811 () = (-x $_) + 3;
1812 ####
1813 # require(foo()) and do(foo())
1814 require (foo());
1815 do (foo());
1816 goto (foo());
1817 CORE::dump (foo());
1818 last (foo());
1819 next (foo());
1820 redo (foo());
1821 ####
1822 # require vstring
1823 require v5.16;
1824 ####
1825 # [perl #97476] not() *does* follow the llafr
1826 $_ = ($a xor not +($1 || 2) ** 2);
1827 ####
1828 # Precedence conundrums with argument-less function calls
1829 () = (eof) + 1;
1830 () = (return) + 1;
1831 () = (return, 1);
1832 () = warn;
1833 () = warn() + 1;
1834 () = setpgrp() + 1;
1835 ####
1836 # loopexes have assignment prec
1837 () = (CORE::dump a) | 'b';
1838 () = (goto a) | 'b';
1839 () = (last a) | 'b';
1840 () = (next a) | 'b';
1841 () = (redo a) | 'b';
1842 ####
1843 # [perl #63558] open local(*FH)
1844 open local *FH;
1845 pipe local *FH, local *FH;
1846 ####
1847 # [perl #91416] open "string"
1848 open 'open';
1849 open '####';
1850 open '^A';
1851 open "\ca";
1852 >>>>
1853 open *open;
1854 open '####';
1855 open '^A';
1856 open *^A;
1857 ####
1858 # "string"->[] ->{}
1859 no strict 'vars';
1860 () = 'open'->[0]; #aelemfast
1861 () = '####'->[0];
1862 () = '^A'->[0];
1863 () = "\ca"->[0];
1864 () = 'a::]b'->[0];
1865 () = 'open'->[$_]; #aelem
1866 () = '####'->[$_];
1867 () = '^A'->[$_];
1868 () = "\ca"->[$_];
1869 () = 'a::]b'->[$_];
1870 () = 'open'->{0}; #helem
1871 () = '####'->{0};
1872 () = '^A'->{0};
1873 () = "\ca"->{0};
1874 () = 'a::]b'->{0};
1875 >>>>
1876 no strict 'vars';
1877 () = $open[0];
1878 () = '####'->[0];
1879 () = '^A'->[0];
1880 () = $^A[0];
1881 () = 'a::]b'->[0];
1882 () = $open[$_];
1883 () = '####'->[$_];
1884 () = '^A'->[$_];
1885 () = $^A[$_];
1886 () = 'a::]b'->[$_];
1887 () = $open{'0'};
1888 () = '####'->{'0'};
1889 () = '^A'->{'0'};
1890 () = $^A{'0'};
1891 () = 'a::]b'->{'0'};
1892 ####
1893 # [perl #74740] -(f()) vs -f()
1894 $_ = -(f());
1895 ####
1896 # require <binop>
1897 require 'a' . $1;
1898 ####
1899 #[perl #30504] foreach-my postfix/prefix difference
1900 $_ = 'foo' foreach my ($foo1, $bar1, $baz1);
1901 foreach (my ($foo2, $bar2, $baz2)) { $_ = 'foo' }
1902 foreach my $i (my ($foo3, $bar3, $baz3)) { $i = 'foo' }
1903 >>>>
1904 $_ = 'foo' foreach (my($foo1, $bar1, $baz1));
1905 foreach $_ (my($foo2, $bar2, $baz2)) {
1906     $_ = 'foo';
1907 }
1908 foreach my $i (my($foo3, $bar3, $baz3)) {
1909     $i = 'foo';
1910 }
1911 ####
1912 #[perl #108224] foreach with continue block
1913 foreach (1 .. 3) { print } continue { print "\n" }
1914 foreach (1 .. 3) { } continue { }
1915 foreach my $i (1 .. 3) { print $i } continue { print "\n" }
1916 foreach my $i (1 .. 3) { } continue { }
1917 >>>>
1918 foreach $_ (1 .. 3) {
1919     print $_;
1920 }
1921 continue {
1922     print "\n";
1923 }
1924 foreach $_ (1 .. 3) {
1925     ();
1926 }
1927 continue {
1928     ();
1929 }
1930 foreach my $i (1 .. 3) {
1931     print $i;
1932 }
1933 continue {
1934     print "\n";
1935 }
1936 foreach my $i (1 .. 3) {
1937     ();
1938 }
1939 continue {
1940     ();
1941 }
1942 ####
1943 # file handles
1944 no strict;
1945 my $mfh;
1946 open F;
1947 open *F;
1948 open $fh;
1949 open $mfh;
1950 open 'a+b';
1951 select *F;
1952 select F;
1953 select $f;
1954 select $mfh;
1955 select 'a+b';
1956 ####
1957 # 'my' works with padrange op
1958 my($z, @z);
1959 my $m1;
1960 $m1 = 1;
1961 $z = $m1;
1962 my $m2 = 2;
1963 my($m3, $m4);
1964 ($m3, $m4) = (1, 2);
1965 @z = ($m3, $m4);
1966 my($m5, $m6) = (1, 2);
1967 my($m7, undef, $m8) = (1, 2, 3);
1968 @z = ($m7, undef, $m8);
1969 ($m7, undef, $m8) = (1, 2, 3);
1970 ####
1971 # 'our/local' works with padrange op
1972 our($z, @z);
1973 our $o1;
1974 no strict;
1975 local $o11;
1976 $o1 = 1;
1977 local $o1 = 1;
1978 $z = $o1;
1979 $z = local $o1;
1980 our $o2 = 2;
1981 our($o3, $o4);
1982 ($o3, $o4) = (1, 2);
1983 local($o3, $o4) = (1, 2);
1984 @z = ($o3, $o4);
1985 @z = local($o3, $o4);
1986 our($o5, $o6) = (1, 2);
1987 our($o7, undef, $o8) = (1, 2, 3);
1988 @z = ($o7, undef, $o8);
1989 @z = local($o7, undef, $o8);
1990 ($o7, undef, $o8) = (1, 2, 3);
1991 local($o7, undef, $o8) = (1, 2, 3);
1992 ####
1993 # 'state' works with padrange op
1994 # CONTEXT no strict; use feature 'state';
1995 state($z, @z);
1996 state $s1;
1997 $s1 = 1;
1998 $z = $s1;
1999 state $s2 = 2;
2000 state($s3, $s4);
2001 ($s3, $s4) = (1, 2);
2002 @z = ($s3, $s4);
2003 # assignment of state lists isn't implemented yet
2004 #state($s5, $s6) = (1, 2);
2005 #state($s7, undef, $s8) = (1, 2, 3);
2006 #@z = ($s7, undef, $s8);
2007 ($s7, undef, $s8) = (1, 2, 3);
2008 ####
2009 # anon arrays with padrange
2010 my($a, $b);
2011 my $c = [$a, $b];
2012 my $d = {$a, $b};
2013 ####
2014 # slices with padrange
2015 my($a, $b);
2016 my(@x, %y);
2017 @x = @x[$a, $b];
2018 @x = @y{$a, $b};
2019 ####
2020 # binops with padrange
2021 my($a, $b, $c);
2022 $c = $a cmp $b;
2023 $c = $a + $b;
2024 $a += $b;
2025 $c = $a - $b;
2026 $a -= $b;
2027 $c = my $a1 cmp $b;
2028 $c = my $a2 + $b;
2029 $a += my $b1;
2030 $c = my $a3 - $b;
2031 $a -= my $b2;
2032 ####
2033 # 'x' with padrange
2034 my($a, $b, $c, $d, @e);
2035 $c = $a x $b;
2036 $a x= $b;
2037 @e = ($a) x $d;
2038 @e = ($a, $b) x $d;
2039 @e = ($a, $b, $c) x $d;
2040 @e = ($a, 1) x $d;
2041 ####
2042 # @_ with padrange
2043 my($a, $b, $c) = @_;
2044 ####
2045 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
2046 # lexical subroutine
2047 # CONTEXT use feature 'lexical_subs';
2048 no warnings "experimental::lexical_subs";
2049 my sub f {}
2050 print f();
2051 >>>>
2052 BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x55"}
2053 my sub f {
2054     
2055 }
2056 print f();
2057 ####
2058 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
2059 # lexical "state" subroutine
2060 # CONTEXT use feature 'state', 'lexical_subs';
2061 no warnings 'experimental::lexical_subs';
2062 state sub f {}
2063 print f();
2064 >>>>
2065 BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x55"}
2066 state sub f {
2067     
2068 }
2069 print f();
2070 ####
2071 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
2072 # lexical subroutine scoping
2073 # CONTEXT use feature 'lexical_subs'; no warnings 'experimental::lexical_subs';
2074 {
2075   {
2076     my sub a { die; }
2077     {
2078       foo();
2079       my sub b;
2080       b ;
2081       main::b();
2082       &main::b;
2083       &main::b();
2084       my $b = \&main::b;
2085       sub b { $b; }
2086     }
2087   }
2088   b();
2089 }
2090 ####
2091 # self-referential lexical subroutine
2092 # CONTEXT use feature 'lexical_subs', 'state'; no warnings 'experimental::lexical_subs';
2093 ();
2094 state sub sb2;
2095 sub sb2 {
2096     sb2 ;
2097 }
2098 ####
2099 # lexical subroutine with outer declaration and inner definition
2100 # CONTEXT use feature 'lexical_subs'; no warnings 'experimental::lexical_subs';
2101 ();
2102 my sub f;
2103 my sub g {
2104     ();
2105     sub f { }
2106 }
2107 ####
2108 # TODO only partially fixed
2109 # lexical state subroutine with outer declaration and inner definition
2110 # CONTEXT use feature 'lexical_subs', 'state'; no warnings 'experimental::lexical_subs';
2111 ();
2112 state sub sb4;
2113 state sub a {
2114     ();
2115     sub sb4 { }
2116 }
2117 state sub sb5;
2118 sub {
2119     ();
2120     sub sb5 { }
2121 } ;
2122 ####
2123 # Elements of %# should not be confused with $#{ array }
2124 () = ${#}{'foo'};
2125 ####
2126 # $; [perl #123357]
2127 $_ = $;;
2128 do {
2129     $;
2130 };
2131 ####
2132 # Ampersand calls and scalar context
2133 # OPTIONS -P
2134 package prototest;
2135 sub foo($$);
2136 foo(bar(),baz());
2137 >>>>
2138 package prototest;
2139 &foo(scalar bar(), scalar baz());
2140 ####
2141 # coderef2text and prototyped sub calls [perl #123435]
2142 is 'foo', 'oo';
2143 ####
2144 # prototypes with unary precedence
2145 package prototest;
2146 sub dollar($) {}
2147 sub optdollar(;$) {}
2148 sub optoptdollar(;;$) {}
2149 sub splat(*) {}
2150 sub optsplat(;*) {}
2151 sub optoptsplat(;;*) {}
2152 sub bar(_) {}
2153 sub optbar(;_) {}
2154 sub optoptbar(;;_) {}
2155 sub plus(+) {}
2156 sub optplus(;+) {}
2157 sub optoptplus(;;+) {}
2158 sub wack(\$) {}
2159 sub optwack(;\$) {}
2160 sub optoptwack(;;\$) {}
2161 sub wackbrack(\[$]) {}
2162 sub optwackbrack(;\[$]) {}
2163 sub optoptwackbrack(;;\[$]) {}
2164 dollar($a < $b);
2165 optdollar($a < $b);
2166 optoptdollar($a < $b);
2167 splat($a < $b);     # Some of these deparse with â€˜&’; if that changes, just
2168 optsplat($a < $b);  # change the tests.
2169 optoptsplat($a < $b);
2170 bar($a < $b);
2171 optbar($a < $b);
2172 optoptbar($a < $b);
2173 plus($a < $b);
2174 optplus($a < $b);
2175 optoptplus($a < $b);
2176 wack($a = $b);
2177 optwack($a = $b);
2178 optoptwack($a = $b);
2179 wackbrack($a = $b);
2180 optwackbrack($a = $b);
2181 optoptwackbrack($a = $b);
2182 >>>>
2183 package prototest;
2184 dollar($a < $b);
2185 optdollar($a < $b);
2186 optoptdollar($a < $b);
2187 &splat($a < $b);
2188 &optsplat($a < $b);
2189 &optoptsplat($a < $b);
2190 bar($a < $b);
2191 optbar($a < $b);
2192 optoptbar($a < $b);
2193 &plus($a < $b);
2194 &optplus($a < $b);
2195 &optoptplus($a < $b);
2196 &wack(\($a = $b));
2197 &optwack(\($a = $b));
2198 &optoptwack(\($a = $b));
2199 &wackbrack(\($a = $b));
2200 &optwackbrack(\($a = $b));
2201 &optoptwackbrack(\($a = $b));
2202 ####
2203 # ensure aelemfast works in the range -128..127 and that there's no
2204 # funky edge cases
2205 my $x;
2206 no strict 'vars';
2207 $x = $a[-256] + $a[-255] + $a[-129] + $a[-128] + $a[-127] + $a[-1] + $a[0];
2208 $x = $a[1] + $a[126] + $a[127] + $a[128] + $a[255] + $a[256];
2209 my @b;
2210 $x = $b[-256] + $b[-255] + $b[-129] + $b[-128] + $b[-127] + $b[-1] + $b[0];
2211 $x = $b[1] + $b[126] + $b[127] + $b[128] + $b[255] + $b[256];
2212 ####
2213 # 'm' must be preserved in m??
2214 m??;
2215 ####
2216 # \(@array) and \(..., (@array), ...)
2217 my(@array, %hash, @a, @b, %c, %d);
2218 () = \(@array);
2219 () = \(%hash);
2220 () = \(@a, (@b), (%c), %d);
2221 () = \(@Foo::array);
2222 () = \(%Foo::hash);
2223 () = \(@Foo::a, (@Foo::b), (%Foo::c), %Foo::d);
2224 ####
2225 # subs synonymous with keywords
2226 main::our();
2227 main::pop();
2228 state();
2229 use feature 'state';
2230 main::state();
2231 ####
2232 # lvalue references
2233 # CONTEXT use feature "state", 'refaliasing', 'lexical_subs'; no warnings 'experimental';
2234 our $x;
2235 \$x = \$x;
2236 my $m;
2237 \$m = \$x;
2238 \my $n = \$x;
2239 (\$x) = @_;
2240 \($x) = @_;
2241 \($m) = @_;
2242 (\$m) = @_;
2243 \my($p) = @_;
2244 (\my $r) = @_;
2245 \($x, my $a) = @{[\$x, \$x]};
2246 (\$x, \my $b) = @{[\$x, \$x]};
2247 \local $x = \3;
2248 \local($x) = \3;
2249 \state $c = \3;
2250 \state($d) = \3;
2251 \our $e = \3;
2252 \our($f) = \3;
2253 \$_[0] = foo();
2254 \($_[1]) = foo();
2255 my @a;
2256 \$a[0] = foo();
2257 \($a[1]) = foo();
2258 \local($a[1]) = foo();
2259 \@a[0,1] = foo();
2260 \(@a[2,3]) = foo();
2261 \local @a[0,1] = (\$a)x2;
2262 \$_{a} = foo();
2263 \($_{b}) = foo();
2264 my %h;
2265 \$h{a} = foo();
2266 \($h{b}) = foo();
2267 \local $h{a} = \$x;
2268 \local($h{b}) = \$x;
2269 \@h{'a','b'} = foo();
2270 \(@h{2,3}) = foo();
2271 \local @h{'a','b'} = (\$x)x2;
2272 \@_ = foo();
2273 \@a = foo();
2274 (\@_) = foo();
2275 (\@a) = foo();
2276 \my @c = foo();
2277 (\my @d) = foo();
2278 \(@_) = foo();
2279 \(@a) = foo();
2280 \my(@g) = foo();
2281 \local @_ = \@_;
2282 (\local @_) = \@_;
2283 \state @e = [1..3];
2284 \state(@f) = \3;
2285 \our @i = [1..3];
2286 \our(@h) = \3;
2287 \%_ = foo();
2288 \%h = foo();
2289 (\%_) = foo();
2290 (\%h) = foo();
2291 \my %c = foo();
2292 (\my %d) = foo();
2293 \local %_ = \%h;
2294 (\local %_) = \%h;
2295 \state %y = {1,2};
2296 \our %z = {1,2};
2297 (\our %zz) = {1,2};
2298 \&a = foo();
2299 (\&a) = foo();
2300 \(&a) = foo();
2301 {
2302   my sub a;
2303   \&a = foo();
2304   (\&a) = foo();
2305   \(&a) = foo();
2306 }
2307 (\$_, $_) = \(1, 2);
2308 $_ == 3 ? \$_ : $_ = \3;
2309 $_ == 3 ? \$_ : \$x = \3;
2310 \($_ == 3 ? $_ : $x) = \3;
2311 for \my $topic (\$1, \$2) {
2312     die;
2313 }
2314 for \state $topic (\$1, \$2) {
2315     die;
2316 }
2317 for \our $topic (\$1, \$2) {
2318     die;
2319 }
2320 for \$_ (\$1, \$2) {
2321     die;
2322 }
2323 for \my @a ([1,2], [3,4]) {
2324     die;
2325 }
2326 for \state @a ([1,2], [3,4]) {
2327     die;
2328 }
2329 for \our @a ([1,2], [3,4]) {
2330     die;
2331 }
2332 for \@_ ([1,2], [3,4]) {
2333     die;
2334 }
2335 for \my %a ({5,6}, {7,8}) {
2336     die;
2337 }
2338 for \our %a ({5,6}, {7,8}) {
2339     die;
2340 }
2341 for \state %a ({5,6}, {7,8}) {
2342     die;
2343 }
2344 for \%_ ({5,6}, {7,8}) {
2345     die;
2346 }
2347 {
2348     my sub a;
2349     for \&a (sub { 9; }, sub { 10; }) {
2350         die;
2351     }
2352 }
2353 for \&a (sub { 9; }, sub { 10; }) {
2354     die;
2355 }
2356 >>>>
2357 our $x;
2358 \$x = \$x;
2359 my $m;
2360 \$m = \$x;
2361 \my $n = \$x;
2362 (\$x) = @_;
2363 (\$x) = @_;
2364 (\$m) = @_;
2365 (\$m) = @_;
2366 (\my $p) = @_;
2367 (\my $r) = @_;
2368 (\$x, \my $a) = @{[\$x, \$x];};
2369 (\$x, \my $b) = @{[\$x, \$x];};
2370 \local $x = \3;
2371 (\local $x) = \3;
2372 \state $c = \3;
2373 (\state $d) = \3;
2374 \our $e = \3;
2375 (\our $f) = \3;
2376 \$_[0] = foo();
2377 (\$_[1]) = foo();
2378 my @a;
2379 \$a[0] = foo();
2380 (\$a[1]) = foo();
2381 (\local $a[1]) = foo();
2382 (\@a[0, 1]) = foo();
2383 (\@a[2, 3]) = foo();
2384 (\local @a[0, 1]) = (\$a) x 2;
2385 \$_{'a'} = foo();
2386 (\$_{'b'}) = foo();
2387 my %h;
2388 \$h{'a'} = foo();
2389 (\$h{'b'}) = foo();
2390 \local $h{'a'} = \$x;
2391 (\local $h{'b'}) = \$x;
2392 (\@h{'a', 'b'}) = foo();
2393 (\@h{2, 3}) = foo();
2394 (\local @h{'a', 'b'}) = (\$x) x 2;
2395 \@_ = foo();
2396 \@a = foo();
2397 (\@_) = foo();
2398 (\@a) = foo();
2399 \my @c = foo();
2400 (\my @d) = foo();
2401 (\(@_)) = foo();
2402 (\(@a)) = foo();
2403 (\(my @g)) = foo();
2404 \local @_ = \@_;
2405 (\local @_) = \@_;
2406 \state @e = [1..3];
2407 (\(state @f)) = \3;
2408 \our @i = [1..3];
2409 (\(our @h)) = \3;
2410 \%_ = foo();
2411 \%h = foo();
2412 (\%_) = foo();
2413 (\%h) = foo();
2414 \my %c = foo();
2415 (\my %d) = foo();
2416 \local %_ = \%h;
2417 (\local %_) = \%h;
2418 \state %y = {1, 2};
2419 \our %z = {1, 2};
2420 (\our %zz) = {1, 2};
2421 \&a = foo();
2422 (\&a) = foo();
2423 (\&a) = foo();
2424 {
2425   my sub a;
2426   \&a = foo();
2427   (\&a) = foo();
2428   (\&a) = foo();
2429 }
2430 (\$_, $_) = \(1, 2);
2431 $_ == 3 ? \$_ : $_ = \3;
2432 $_ == 3 ? \$_ : \$x = \3;
2433 ($_ == 3 ? \$_ : \$x) = \3;
2434 foreach \my $topic (\$1, \$2) {
2435     die;
2436 }
2437 foreach \state $topic (\$1, \$2) {
2438     die;
2439 }
2440 foreach \our $topic (\$1, \$2) {
2441     die;
2442 }
2443 foreach \$_ (\$1, \$2) {
2444     die;
2445 }
2446 foreach \my @a ([1, 2], [3, 4]) {
2447     die;
2448 }
2449 foreach \state @a ([1, 2], [3, 4]) {
2450     die;
2451 }
2452 foreach \our @a ([1, 2], [3, 4]) {
2453     die;
2454 }
2455 foreach \@_ ([1, 2], [3, 4]) {
2456     die;
2457 }
2458 foreach \my %a ({5, 6}, {7, 8}) {
2459     die;
2460 }
2461 foreach \our %a ({5, 6}, {7, 8}) {
2462     die;
2463 }
2464 foreach \state %a ({5, 6}, {7, 8}) {
2465     die;
2466 }
2467 foreach \%_ ({5, 6}, {7, 8}) {
2468     die;
2469 }
2470 {
2471     my sub a;
2472     foreach \&a (sub { 9; } , sub { 10; } ) {
2473         die;
2474     }
2475 }
2476 foreach \&a (sub { 9; } , sub { 10; } ) {
2477     die;
2478 }
2479 ####
2480 # join $foo, pos
2481 my $foo;
2482 $_ = join $foo, pos
2483 >>>>
2484 my $foo;
2485 $_ = join('???', pos $_);
2486 ####
2487 # exists $a[0]
2488 our @a;
2489 exists $a[0];
2490 ####
2491 # my @a; exists $a[0]
2492 my @a;
2493 exists $a[0];
2494 ####
2495 # delete $a[0]
2496 our @a;
2497 delete $a[0];
2498 ####
2499 # my @a; delete $a[0]
2500 my @a;
2501 delete $a[0];
2502 ####
2503 # $_[0][$_[1]]
2504 $_[0][$_[1]];
2505 ####
2506 # f($a[0]);
2507 my @a;
2508 f($a[0]);
2509 ####
2510 #qr/\Q$h{'key'}\E/;
2511 my %h;
2512 qr/\Q$h{'key'}\E/;
2513 ####
2514 # my $x = "$h{foo}";
2515 my %h;
2516 my $x = "$h{'foo'}";
2517 ####
2518 # weird constant hash key
2519 my %h;
2520 my $x = $h{"\000\t\x{100}"};
2521 ####
2522 # multideref and packages
2523 package foo;
2524 my(%bar) = ('a', 'b');
2525 our(@bar) = (1, 2);
2526 $bar{'k'} = $bar[200];
2527 $main::bar{'k'} = $main::bar[200];
2528 $foo::bar{'k'} = $foo::bar[200];
2529 package foo2;
2530 $bar{'k'} = $bar[200];
2531 $main::bar{'k'} = $main::bar[200];
2532 $foo::bar{'k'} = $foo::bar[200];
2533 >>>>
2534 package foo;
2535 my(%bar) = ('a', 'b');
2536 our(@bar) = (1, 2);
2537 $bar{'k'} = $bar[200];
2538 $main::bar{'k'} = $main::bar[200];
2539 $foo::bar{'k'} = $bar[200];
2540 package foo2;
2541 $bar{'k'} = $foo::bar[200];
2542 $main::bar{'k'} = $main::bar[200];
2543 $foo::bar{'k'} = $foo::bar[200];
2544 ####
2545 # multideref and local
2546 my %h;
2547 local $h{'foo'}[0] = 1;
2548 ####
2549 # multideref and exists
2550 my(%h, $i);
2551 my $e = exists $h{'foo'}[$i];
2552 ####
2553 # multideref and delete
2554 my(%h, $i);
2555 my $e = delete $h{'foo'}[$i];
2556 ####
2557 # multideref with leading expression
2558 my $r;
2559 my $x = +($r // [])->{'foo'}[0];
2560 ####
2561 # multideref with complex middle index
2562 my(%h, $i, $j, $k);
2563 my $x = $h{'foo'}[$i + $j]{$k};
2564 ####
2565 # multideref with trailing non-simple index that initially looks simple
2566 # (i.e. the constant "3")
2567 my($r, $i, $j, $k);
2568 my $x = +($r || {})->{'foo'}[$i + $j]{3 + $k};
2569 ####
2570 # chdir
2571 chdir 'file';
2572 chdir FH;
2573 chdir;
2574 ####
2575 # 5.22 bitops
2576 # CONTEXT use feature "bitwise"; no warnings "experimental::bitwise";
2577 $_ = $_ | $_;
2578 $_ = $_ & $_;
2579 $_ = $_ ^ $_;
2580 $_ = ~$_;
2581 $_ = $_ |. $_;
2582 $_ = $_ &. $_;
2583 $_ = $_ ^. $_;
2584 $_ = ~.$_;
2585 $_ |= $_;
2586 $_ &= $_;
2587 $_ ^= $_;
2588 $_ |.= $_;
2589 $_ &.= $_;
2590 $_ ^.= $_;
2591 ####
2592 ####
2593 # Should really use 'no warnings "experimental::signatures"',
2594 # but it doesn't yet deparse correctly.
2595 # anon subs used because this test framework doesn't deparse named subs
2596 # in the DATA code snippets.
2597 #
2598 # general signature
2599 no warnings;
2600 use feature 'signatures';
2601 my $x;
2602 sub ($a, $, $b = $glo::bal, $c = $a, $d = 'foo', $e = -37, $f = 0, $g = 1, $h = undef, $i = $a + 1, $j = /foo/, @) {
2603     $x++;
2604 }
2605 ;
2606 $x++;
2607 ####
2608 # Signature and prototype
2609 no warnings;
2610 use feature 'signatures';
2611 my $x;
2612 my $f = sub : prototype($$) ($a, $b) {
2613     $x++;
2614 }
2615 ;
2616 $x++;
2617 ####
2618 # Signature and prototype and attrs
2619 no warnings;
2620 use feature 'signatures';
2621 my $x;
2622 my $f = sub : prototype($$) lvalue ($a, $b) {
2623     $x++;
2624 }
2625 ;
2626 $x++;
2627 ####
2628 # Signature and attrs
2629 no warnings;
2630 use feature 'signatures';
2631 my $x;
2632 my $f = sub : lvalue method ($a, $b) {
2633     $x++;
2634 }
2635 ;
2636 $x++;
2637 ####
2638 # named array slurp, null body
2639 no warnings;
2640 use feature 'signatures';
2641 sub (@a) {
2642     ;
2643 }
2644 ;
2645 ####
2646 # named hash slurp
2647 no warnings;
2648 use feature 'signatures';
2649 sub ($key, %h) {
2650     $h{$key};
2651 }
2652 ;
2653 ####
2654 # anon hash slurp
2655 no warnings;
2656 use feature 'signatures';
2657 sub ($a, %) {
2658     $a;
2659 }
2660 ;
2661 ####
2662 # parenthesised default arg
2663 no warnings;
2664 use feature 'signatures';
2665 sub ($a, $b = (/foo/), $c = 1) {
2666     $a + $b + $c;
2667 }
2668 ;
2669 ####
2670 # parenthesised default arg with TARGMY
2671 no warnings;
2672 use feature 'signatures';
2673 sub ($a, $b = ($a + 1), $c = 1) {
2674     $a + $b + $c;
2675 }
2676 ;
2677 ####
2678 # empty default
2679 no warnings;
2680 use feature 'signatures';
2681 sub ($a, $=) {
2682     $a;
2683 }
2684 ;
2685 ####
2686 # padrange op within pattern code blocks
2687 /(?{ my($x, $y) = (); })/;
2688 my $a;
2689 /$a(?{ my($x, $y) = (); })/;
2690 my $r1 = qr/(?{ my($x, $y) = (); })/;
2691 my $r2 = qr/$a(?{ my($x, $y) = (); })/;
2692 ####
2693 # don't remove pattern whitespace escapes
2694 /a\ b/;
2695 /a\ b/x;
2696 /a\     b/;
2697 /a\     b/x;
2698 ####
2699 # my attributes
2700 my $s1 :foo(f1, f2) bar(b1, b2);
2701 my @a1 :foo(f1, f2) bar(b1, b2);
2702 my %h1 :foo(f1, f2) bar(b1, b2);
2703 my($s2, @a2, %h2) :foo(f1, f2) bar(b1, b2);
2704 ####
2705 # my class attributes
2706 package Foo::Bar;
2707 my Foo::Bar $s1 :foo(f1, f2) bar(b1, b2);
2708 my Foo::Bar @a1 :foo(f1, f2) bar(b1, b2);
2709 my Foo::Bar %h1 :foo(f1, f2) bar(b1, b2);
2710 my Foo::Bar ($s2, @a2, %h2) :foo(f1, f2) bar(b1, b2);
2711 package main;
2712 my Foo::Bar $s3 :foo(f1, f2) bar(b1, b2);
2713 my Foo::Bar @a3 :foo(f1, f2) bar(b1, b2);
2714 my Foo::Bar %h3 :foo(f1, f2) bar(b1, b2);
2715 my Foo::Bar ($s4, @a4, %h4) :foo(f1, f2) bar(b1, b2);
2716 ####
2717 # avoid false positives in my $x :attribute
2718 'attributes'->import('main', \my $x1, 'foo(bar)'), my $y1;
2719 'attributes'->import('Fooo', \my $x2, 'foo(bar)'), my $y2;
2720 ####
2721 # hash slices and hash key/value slices
2722 my(@a, %h);
2723 our(@oa, %oh);
2724 @a = @h{'foo', 'bar'};
2725 @a = %h{'foo', 'bar'};
2726 @a = delete @h{'foo', 'bar'};
2727 @a = delete %h{'foo', 'bar'};
2728 @oa = @oh{'foo', 'bar'};
2729 @oa = %oh{'foo', 'bar'};
2730 @oa = delete @oh{'foo', 'bar'};
2731 @oa = delete %oh{'foo', 'bar'};
2732 ####
2733 # keys optimised away in void and scalar context
2734 no warnings;
2735 ;
2736 our %h1;
2737 my($x, %h2);
2738 %h1;
2739 keys %h1;
2740 $x = %h1;
2741 $x = keys %h1;
2742 %h2;
2743 keys %h2;
2744 $x = %h2;
2745 $x = keys %h2;
2746 ####
2747 # eq,const optimised away for (index() == -1)
2748 my($a, $b);
2749 our $c;
2750 $c = index($a, $b) == 2;
2751 $c = rindex($a, $b) == 2;
2752 $c = index($a, $b) == -1;
2753 $c = rindex($a, $b) == -1;
2754 $c = index($a, $b) != -1;
2755 $c = rindex($a, $b) != -1;
2756 $c = (index($a, $b) == -1);
2757 $c = (rindex($a, $b) == -1);
2758 $c = (index($a, $b) != -1);
2759 $c = (rindex($a, $b) != -1);
2760 ####
2761 # eq,const,sassign,madmy optimised away for (index() == -1)
2762 my($a, $b);
2763 my $c;
2764 $c = index($a, $b) == 2;
2765 $c = rindex($a, $b) == 2;
2766 $c = index($a, $b) == -1;
2767 $c = rindex($a, $b) == -1;
2768 $c = index($a, $b) != -1;
2769 $c = rindex($a, $b) != -1;
2770 $c = (index($a, $b) == -1);
2771 $c = (rindex($a, $b) == -1);
2772 $c = (index($a, $b) != -1);
2773 $c = (rindex($a, $b) != -1);
2774 ####
2775 # plain multiconcat
2776 my($a, $b, $c, $d, @a);
2777 $d = length $a . $b . $c;
2778 $d = length($a) . $b . $c;
2779 print '' . $a;
2780 push @a, ($a . '') * $b;
2781 unshift @a, "$a" * ($b . '');
2782 print $a . 'x' . $b . $c;
2783 print $a . 'x' . $b . $c, $d;
2784 print $b . $c . ($a . $b);
2785 print $b . $c . ($a . $b);
2786 print $b . $c . @a;
2787 print $a . "\x{100}";
2788 ####
2789 # double-quoted multiconcat
2790 my($a, $b, $c, $d, @a);
2791 print "${a}x\x{100}$b$c";
2792 print "$a\Q$b\E$c\Ua$a\E\Lb$b\uc$c\E$a${b}c$c";
2793 print "A=$a[length 'b' . $c . 'd'] b=$b";
2794 print "A=@a B=$b";
2795 print "\x{101}$a\x{100}";
2796 $a = qr/\Q
2797 $b $c
2798 \x80
2799 \x{100}
2800 \E$c
2801 /;
2802 ####
2803 # sprintf multiconcat
2804 my($a, $b, $c, $d, @a);
2805 print sprintf("%s%s%%%sx%s\x{100}%s", $a, $b, $c, scalar @a, $d);
2806 ####
2807 # multiconcat with lexical assign
2808 my($a, $b, $c, $d, $e, @a);
2809 $d = 'foo' . $a;
2810 $d = "foo$a";
2811 $d = $a . '';
2812 $d = 'foo' . $a . 'bar';
2813 $d = $a . $b;
2814 $d = $a . $b . $c;
2815 $d = $a . $b . $c . @a;
2816 $e = ($d = $a . $b . $c);
2817 $d = !$a . $b . $c;
2818 $a = $b . $c . ($a . $b);
2819 $e = f($d = !$a . $b) . $c;
2820 $d = "${a}x\x{100}$b$c";
2821 f($d = !$a . $b . $c);
2822 ####
2823 # multiconcat with lexical my
2824 my($a, $b, $c, $d, $e, @a);
2825 my $d1 = 'foo' . $a;
2826 my $d2 = "foo$a";
2827 my $d3 = $a . '';
2828 my $d4 = 'foo' . $a . 'bar';
2829 my $d5 = $a . $b;
2830 my $d6 = $a . $b . $c;
2831 my $e7 = ($d = $a . $b . $c);
2832 my $d8 = !$a . $b . $c;
2833 my $d9 = $b . $c . ($a . $b);
2834 my $da = f($d = !$a . $b) . $c;
2835 my $dc = "${a}x\x{100}$b$c";
2836 f(my $db = !$a . $b . $c);
2837 my $dd = $a . $b . $c . @a;
2838 ####
2839 # multiconcat with lexical append
2840 my($a, $b, $c, $d, $e, @a);
2841 $d .= '';
2842 $d .= $a;
2843 $d .= "$a";
2844 $d .= 'foo' . $a;
2845 $d .= "foo$a";
2846 $d .= $a . '';
2847 $d .= 'foo' . $a . 'bar';
2848 $d .= $a . $b;
2849 $d .= $a . $b . $c;
2850 $d .= $a . $b . @a;
2851 $e .= ($d = $a . $b . $c);
2852 $d .= !$a . $b . $c;
2853 $a .= $b . $c . ($a . $b);
2854 $e .= f($d .= !$a . $b) . $c;
2855 f($d .= !$a . $b . $c);
2856 $d .= "${a}x\x{100}$b$c";
2857 ####
2858 # multiconcat with expression assign
2859 my($a, $b, $c, @a);
2860 our($d, $e);
2861 $d = 'foo' . $a;
2862 $d = "foo$a";
2863 $d = $a . '';
2864 $d = 'foo' . $a . 'bar';
2865 $d = $a . $b;
2866 $d = $a . $b . $c;
2867 $d = $a . $b . @a;
2868 $e = ($d = $a . $b . $c);
2869 $a["-$b-"] = !$a . $b . $c;
2870 $a[$b]{$c}{$d ? $a : $b . $c} = !$a . $b . $c;
2871 $a = $b . $c . ($a . $b);
2872 $e = f($d = !$a . $b) . $c;
2873 $d = "${a}x\x{100}$b$c";
2874 f($d = !$a . $b . $c);
2875 ####
2876 # multiconcat with expression concat
2877 my($a, $b, $c, @a);
2878 our($d, $e);
2879 $d .= 'foo' . $a;
2880 $d .= "foo$a";
2881 $d .= $a . '';
2882 $d .= 'foo' . $a . 'bar';
2883 $d .= $a . $b;
2884 $d .= $a . $b . $c;
2885 $d .= $a . $b . @a;
2886 $e .= ($d .= $a . $b . $c);
2887 $a["-$b-"] .= !$a . $b . $c;
2888 $a[$b]{$c}{$d ? $a : $b . $c} .= !$a . $b . $c;
2889 $a .= $b . $c . ($a . $b);
2890 $e .= f($d .= !$a . $b) . $c;
2891 $d .= "${a}x\x{100}$b$c";
2892 f($d .= !$a . $b . $c);
2893 ####
2894 # multiconcat with CORE::sprintf
2895 # CONTEXT sub sprintf {}
2896 my($a, $b);
2897 my $x = CORE::sprintf('%s%s', $a, $b);
2898 ####
2899 # multiconcat with backticks
2900 my($a, $b);
2901 our $x;
2902 $x = `$a-$b`;
2903 ####
2904 # multiconcat within qr//
2905 my($r, $a, $b);
2906 $r = qr/abc\Q$a-$b\Exyz/;
2907 ####
2908 # tr with unprintable characters
2909 my $str;
2910 $str = 'foo';
2911 $str =~ tr/\cA//;
2912 ####
2913 # CORE::foo special case in bareword parsing
2914 print $CORE::foo, $CORE::foo::bar;
2915 print @CORE::foo, @CORE::foo::bar;
2916 print %CORE::foo, %CORE::foo::bar;
2917 print $CORE::foo{'a'}, $CORE::foo::bar{'a'};
2918 print &CORE::foo, &CORE::foo::bar;
2919 print &CORE::foo(), &CORE::foo::bar();
2920 print \&CORE::foo, \&CORE::foo::bar;
2921 print *CORE::foo, *CORE::foo::bar;
2922 print stat CORE::foo::, stat CORE::foo::bar;
2923 print CORE::foo:: 1;
2924 print CORE::foo::bar 2;
2925 ####
2926 # trailing colons on glob names
2927 no strict 'vars';
2928 $Foo::::baz = 1;
2929 print $foo, $foo::, $foo::::;
2930 print @foo, @foo::, @foo::::;
2931 print %foo, %foo::, %foo::::;
2932 print $foo{'a'}, $foo::{'a'}, $foo::::{'a'};
2933 print &foo, &foo::, &foo::::;
2934 print &foo(), &foo::(), &foo::::();
2935 print \&foo, \&foo::, \&foo::::;
2936 print *foo, *foo::, *foo::::;
2937 print stat Foo, stat Foo::::;
2938 print Foo 1;
2939 print Foo:::: 2;
2940 ####
2941 # trailing colons mixed with CORE
2942 no strict 'vars';
2943 print $CORE, $CORE::, $CORE::::;
2944 print @CORE, @CORE::, @CORE::::;
2945 print %CORE, %CORE::, %CORE::::;
2946 print $CORE{'a'}, $CORE::{'a'}, $CORE::::{'a'};
2947 print &CORE, &CORE::, &CORE::::;
2948 print &CORE(), &CORE::(), &CORE::::();
2949 print \&CORE, \&CORE::, \&CORE::::;
2950 print *CORE, *CORE::, *CORE::::;
2951 print stat CORE, stat CORE::::;
2952 print CORE 1;
2953 print CORE:::: 2;
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 $CORE::foo{'a'}, $CORE::foo::{'a'}, $CORE::foo::::{'a'};
2958 print &CORE::foo, &CORE::foo::, &CORE::foo::::;
2959 print &CORE::foo(), &CORE::foo::(), &CORE::foo::::();
2960 print \&CORE::foo, \&CORE::foo::, \&CORE::foo::::;
2961 print *CORE::foo, *CORE::foo::, *CORE::foo::::;
2962 print stat CORE::foo::, stat CORE::foo::::;
2963 print CORE::foo:: 1;
2964 print CORE::foo:::: 2;
2965 ####
2966 # \&foo
2967 my sub foo {
2968     1;
2969 }
2970 no strict 'vars';
2971 print \&main::foo;
2972 print \&{foo};
2973 print \&bar;
2974 use strict 'vars';
2975 print \&main::foo;
2976 print \&{foo};
2977 print \&main::bar;
2978 ####
2979 # exists(&foo)
2980 my sub foo {
2981     1;
2982 }
2983 no strict 'vars';
2984 print exists &main::foo;
2985 print exists &{foo};
2986 print exists &bar;
2987 use strict 'vars';
2988 print exists &main::foo;
2989 print exists &{foo};
2990 print exists &main::bar;
2991 # precedence of optimised-away 'keys' (OPpPADHV_ISKEYS/OPpRV2HV_ISKEYS)
2992 my($r1, %h1, $res);
2993 our($r2, %h2);
2994 $res = keys %h1;
2995 $res = keys %h2;
2996 $res = keys %$r1;
2997 $res = keys %$r2;
2998 $res = keys(%h1) / 2 - 1;
2999 $res = keys(%h2) / 2 - 1;
3000 $res = keys(%$r1) / 2 - 1;
3001 $res = keys(%$r2) / 2 - 1;
3002 ####
3003 # ditto in presence of sub keys {}
3004 # CONTEXT sub keys {}
3005 no warnings;
3006 my($r1, %h1, $res);
3007 our($r2, %h2);
3008 CORE::keys %h1;
3009 CORE::keys(%h1) / 2;
3010 $res = CORE::keys %h1;
3011 $res = CORE::keys %h2;
3012 $res = CORE::keys %$r1;
3013 $res = CORE::keys %$r2;
3014 $res = CORE::keys(%h1) / 2 - 1;
3015 $res = CORE::keys(%h2) / 2 - 1;
3016 $res = CORE::keys(%$r1) / 2 - 1;
3017 $res = CORE::keys(%$r2) / 2 - 1;
3018 ####
3019 # concat: STACKED: ambiguity between .= and optimised nested
3020 my($a, $b);
3021 $b = $a . $a . $a;
3022 (($a .= $a) .= $a) .= $a;
3023 ####
3024 # multiconcat: $$ within string
3025 my($a, $x);
3026 $x = "${$}abc";
3027 $x = "\$$a";
3028 ####
3029 # single state aggregate assignment
3030 # CONTEXT use feature "state";
3031 state @a = (1, 2, 3);
3032 state %h = ('a', 1, 'b', 2);
3033 ####
3034 # state var with attribute
3035 # CONTEXT use feature "state";
3036 state $x :shared;
3037 state $y :shared = 1;
3038 state @a :shared;
3039 state @b :shared = (1, 2);
3040 state %h :shared;
3041 state %i :shared = ('a', 1, 'b', 2);
3042 ####
3043 # \our @a shouldn't be a list
3044 my $r = \our @a;
3045 my(@l) = \our((@b));
3046 @l = \our(@c, @d);