4 splice @INC, 0, 0, 't', '.';
6 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
7 print "1..0 # Skip -- Perl configured without B module\n";
16 my $tests = 46; # not counting those in the __DATA__ section
19 my $deparse = B::Deparse->new();
20 isa_ok($deparse, 'B::Deparse', 'instantiate a B::Deparse object');
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};
37 die "# In \U$what\E code reason:\n# $meta{$what}\n$@";
45 die "Missing name in test $_" unless defined $desc;
48 SKIP: { skip($meta{skip}) };
52 my ($input, $expected);
53 if (/(.*)\n>>>>\n(.*)/s) {
54 ($input, $expected) = ($1, $2);
57 ($input, $expected) = ($_, $_);
60 # parse options if necessary
61 my $deparse = $meta{options}
62 ? $deparse{$meta{options}} ||=
63 new B::Deparse split /,/, $meta{options}
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);
70 ($hint_bits, $warning_bits, $hinthash) = ($^H, ${^WARNING_BITS}, \%^H);
72 $deparse->ambient_pragmas (
73 hint_bits => $hint_bits,
74 warning_bits => $warning_bits,
78 my $coderef = eval $code;
80 local $::TODO = $meta{todo};
82 is($@, "", "compilation of $desc")
83 or diag "=============================================\n"
84 . "CODE:\n--------\n$code\n--------\n"
85 . "=============================================\n";
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*\}$';
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";
103 # Reset the ambient pragmas
107 ($b, $w, $h) = ($^H, ${^WARNING_BITS}, \%^H);
109 $deparse->ambient_pragmas (
116 use constant 'c', 'stuff';
117 is((eval "sub ".$deparse->coderef2text(\&c))->(), 'stuff',
118 'the subroutine generated by use constant deparses');
121 is($deparse->coderef2text(sub{(-1) ** $a }), "{\n (-1) ** \$a;\n}",
122 'anon sub capturing an external lexical');
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');
130 my $path = join " ", map { qq["-I$_"] } @INC;
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"; }
139 BEGIN { $/ = "\n"; $\ = "\n"; }
140 LINE: while (defined($_ = readline ARGV)) {
142 our(@F) = split(' ', $_, 0);
146 $b =~ s/our\\\(\\\@F\\\)/our[( ]\@F\\)?/; # accept both our @F and our(@F)
148 'command line flags deparse as BEGIN blocks setting control variables');
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");
155 #Re: perlbug #35857, patch #24505
156 #handle warnings::register-ed packages properly.
157 package B::Deparse::Wrapper;
160 use warnings::register;
162 my $deparser = B::Deparse->new();
163 return $deparser->coderef2text(shift);
167 use overload '0+' => sub { 42 };
172 use constant GLIPP => 'glipp';
173 use constant PI => 4;
174 use constant OVERLOADED_NUMIFICATION => bless({}, 'Moo');
175 use Fcntl qw/O_TRUNC O_APPEND O_EXCL/;
176 BEGIN { delete $::Fcntl::{O_APPEND}; }
177 use POSIX qw/O_CREAT/;
180 my $res = B::Deparse::Wrapper::getcode($val);
181 like($res, qr/use warnings/,
182 '[perl #35857] [PATCH] B::Deparse doesnt handle warnings register properly');
185 my $x=sub { ++$q,++$p };
187 eval <<EOFCODE and test($x);
191 use warnings::register;
196 # Exotic sub declarations
197 $a = `$^X $path "-MO=Deparse" -e "sub ::::{}sub ::::::{}" 2>&1`;
198 $a =~ s/-e syntax OK\n//g;
199 is($a, <<'EOCODG', "sub :::: and sub ::::::");
209 $a = `$^X $path "-MO=Deparse,-l" -e "map{ eval(0) }()" 2>&1`;
210 $a =~ s/-e syntax OK\n//g;
211 is($a, <<'EOCODH', "[perl #117311] [PATCH] -l option ('#line ...') does not emit ^Ls in the output");
220 my $code = <<"EOCODE";
222 our \$\x{1e1f}\x{14d}\x{14d};
226 = $deparse->coderef2text(eval "sub { our \$\x{1e1f}\x{14d}\x{14d} }" );
227 s/$ \n//x for $deparsed, $code;
228 is $deparsed, $code, 'our $funny_Unicode_chars';
233 `$^X $path "-MO=Deparse" -e "BEGIN{*CORE::GLOBAL::require=sub{1}}" 2>&1`;
234 $a =~ s/-e syntax OK\n//g;
235 is($a, <<'EOCODF', "CORE::GLOBAL::require override causing panick");
237 *CORE::GLOBAL::require = sub {
246 `$^X $path "-MO=Deparse" -e "BEGIN{*Acme::Acme:: = *Acme::}" 2>&1`;
247 like($a, qr/-e syntax OK/,
248 "Deparse does not hang when traversing stash circularities");
252 is($deparse->coderef2text(sub{ print "foo@{]}" }),
255 }>, 'curly around to interpolate "@{]}"');
256 is($deparse->coderef2text(sub{ print "foo@{-}" }),
259 }>, 'no need to curly around to interpolate "@-"');
261 # Strict hints in %^H are mercilessly suppressed
263 `$^X $path "-MO=Deparse" -e "use strict; print;" 2>&1`;
264 unlike($a, qr/BEGIN/,
265 "Deparse does not emit strict hh hints");
267 # ambient_pragmas should not mess with strict settings.
269 skip "requires 5.11", 1 unless $] >= 5.011;
272 # Clear out all hints
275 new B::Deparse -> ambient_pragmas(strict => 'all');
277 use 5.011; # should enable strict
278 ok !eval '$do_noT_create_a_variable_with_this_name = 1',
279 'ambient_pragmas do not mess with compiling scope';
283 # multiple statements on format lines
284 $a = `$^X $path "-MO=Deparse" -e "format =" -e "\@" -e "x();z()" -e. 2>&1`;
285 $a =~ s/-e syntax OK\n//g;
286 is($a, <<'EOCODH', 'multiple statements on format lines');
293 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path, '-T' ],
294 prog => "format =\n\@\n\$;\n.\n"),
295 <<'EOCODM', '$; on format line';
302 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse,-l', $path ],
303 prog => "format =\n\@\n\$foo\n.\n"),
304 <<'EOCODM', 'formats with -l';
311 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
312 prog => "{ my \$x; format =\n\@\n\$x\n.\n}"),
313 <<'EOCODN', 'formats nested inside blocks';
324 $a = readpipe qq`$^X $path "-MO=Deparse" -e "use feature q|:all|;`
325 .qq` my sub format; CORE::format =" -e. 2>&1`;
326 like($a, qr/CORE::format/, 'CORE::format when lex format sub is in scope');
328 # literal big chars under 'use utf8'
329 is($deparse->coderef2text(sub{ use utf8; /€/; }),
335 # STDERR when deparsing sub calls
336 # For a short while the output included 'While deparsing'
337 $a = `$^X $path "-MO=Deparse" -e "foo()" 2>&1`;
338 $a =~ s/-e syntax OK\n//g;
339 is($a, <<'EOCODI', 'no extra output when deparsing foo()');
343 # Sub calls compiled before importation
344 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
347 Test::More::->import;
351 'sub calls compiled before importation of prototype subs';
353 # [perl #121050] Prototypes with whitespace
354 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
356 sub _121050(\$ \$) { }
358 sub _121050empty( ) {}
359 () = _121050empty() + 1;
361 <<'EOCODP', '[perl #121050] prototypes with whitespace';
362 sub _121050 (\$ \$) {
366 sub _121050empty ( ) {
369 () = _121050empty + 1;
373 $a = readpipe qq`$^X $path "-MO=Deparse" -Xe `
374 .qq`"use feature q|:all|; my sub no; CORE::no less" 2>&1`;
375 like($a, qr/my sub no;\n.*CORE::no less;/s,
376 'CORE::no after my sub no');
379 $a = readpipe qq`$^X $path "-MO=Deparse" -Xe `
380 .qq`"use feature q|:all|; my sub use; CORE::use less" 2>&1`;
381 like($a, qr/my sub use;\n.*CORE::use less;/s,
382 'CORE::use after my sub use');
385 $a = readpipe qq`$^X $path "-MO=Deparse" -Xe `
386 .qq`"use feature q|:all|; my sub __DATA__; `
387 .qq`CORE::__DATA__" 2>&1`;
388 like($a, qr/my sub __DATA__;\n.*CORE::__DATA__/s,
389 'CORE::__DATA__ after my sub __DATA__');
392 $a = readpipe qq`$^X $path "-MO=Deparse" -e "sub foo{}" 2>&1`;
393 like($a, qr/sub foo\s*\{\s+\}/, 'sub declarations');
394 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
395 prog => 'sub f($); sub f($){}'),
396 qr/sub f\s*\(\$\)\s*\{\s*\}/,
397 'predeclared prototyped subs';
398 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
399 prog => 'use Scalar::Util q-weaken-;
401 BEGIN { weaken($_=\$::{f}) }'),
402 qr/sub f\s*\(\$\)\s*;/,
403 'prototyped stub with weak reference to the stash entry';
404 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
405 prog => 'sub f () { 42 }'),
406 qr/sub f\s*\(\)\s*\{\s*42;\s*\}/,
407 'constant perl sub declaration';
411 skip "BEGIN output is wrong on old perls", 1 if $] < 5.021006;
425 $a = readpipe qq`$^X $path "-MO=Deparse" -e "$prog" 2>&1`;
426 $a =~ s/-e syntax OK\n//g;
427 is($a, <<'EOCODJ', 'BEGIN blocks');
447 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ], prog => '
456 '), <<'EOCODL', 'BEGIN blocks at the end of their enclosing blocks';
473 # BEGIN blocks should not be called __ANON__
474 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
475 prog => 'sub BEGIN { } CHECK { delete $::{BEGIN} }'),
476 qr/sub BEGIN/, 'anonymised BEGIN';
479 my $prog = 'use constant FOO => do { 1 }; no overloading; die';
480 $a = readpipe qq`$^X $path "-MO=-qq,Deparse" -e "$prog" 2>&1`;
481 is($a, <<'EOCODK', '[perl #115066] use statements accidentally nested');
482 use constant ('FOO', do {
489 # BEGIN blocks inside predeclared subs
490 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
494 sub run_tests { BEGIN { } die }'),
495 qr/sub run_tests \{\s*sub BEGIN/,
496 'BEGIN block inside predeclared sub';
498 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
499 prog => 'package foo; use overload qr=>sub{}'),
500 qr/package foo;\s*use overload/,
503 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
504 prog => 'use feature lexical_subs=>; my sub f;sub main::f{}'),
505 qr/^sub main::f \{/m,
506 'sub decl when lex sub is in scope';
508 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
509 prog => 'sub foo{foo()}'),
510 qr/^sub foo \{\s+foo\(\)/m,
513 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
514 prog => 'use feature lexical_subs=>state=>;
515 state sub sb5; sub { sub sb5 { } }'),
516 qr/sub \{\s*\(\);\s*sub sb5 \{/m,
517 'state sub in anon sub but declared outside';
519 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
520 prog => 'BEGIN { $::{f}=\!0 }'),
521 "sub BEGIN {\n \$main::{'f'} = \\1;\n}\n",
522 '&PL_sv_yes constant (used to croak)';
524 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path, '-T' ],
525 prog => '$x =~ (1?/$a/:0)'),
526 '$x =~ ($_ =~ /$a/);'."\n",
527 '$foo =~ <branch-folded match> under taint mode';
529 unlike runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path, '-w' ],
530 prog => 'BEGIN { undef &foo }'),
531 qr'Use of uninitialized value',
532 'no warnings for undefined sub';
534 done_testing($tests);
537 # TODO [perl #120950] This succeeds when run a 2nd time
541 # y/uni/code/ [perl #120950] This 2nd instance succeeds
547 # Constants in a block
548 # CONTEXT no warnings;
554 # List of constants in void context
555 # CONTEXT no warnings;
562 # Lexical and simple arithmetic
564 ++$test and $test /= 2;
567 $test /= 2 if ++$test;
572 # Assignment to list x
573 ((undef) x 3) = undef;
577 my $test = sub : lvalue {
585 my $test = sub : method {
591 # anonsub attrs at statement start
592 my $x = do { +sub : lvalue { my $y; } };
593 my $z = do { foo: +sub : method { my $a; } };
595 # block with continue
603 # lexical and package scalars
607 # lexical and package arrays
612 # lexical and package hashes
617 our($foo, $bar, $baz);
619 # CONTEXT { package Dog } use feature "state";
620 # variables with declared classes
630 my Dog ($foo, @bar, %baz);
631 our Dog ($phoo, @barr, %bazz);
632 state Dog ($fough, @barre, %bazze);
636 local our($rhu, $barb);
640 $_ .= <> . <ARGV> . <$foo>;
646 $_ .= readline(ARGV) . readline(ARGV) . readline($foo);
666 my $foo = "Ab\x{100}\200\x{200}\237Cd\000Ef\x{1000}\cA\x{2000}\cZ";
670 # TODO ? ord("A") != 65 && "EBCDIC"
671 my $baz = "B\366\x{100}";
672 my $bba = qr/B\366\x{100}/;
677 s/x/complex_expression();/e;
692 # 2 arguments in a 3 argument for
693 for (my $i = 0; $i < 2;) {
698 for (my $i = 0; $i < 2; ++$i) {
702 # 3 argument for again
703 for (my $i = 0; $i < 2; ++$i) {
707 # 3-argument for with inverted condition
708 for (my $i; not $i;) {
711 for (my $i; not $i; ++$i) {
714 for (my $a; not +($1 || 2) ** 2;) {
717 Something_to_put_the_loop_in_void_context();
721 while ($i) { my $z = 1; } continue { $i = 99; }
724 foreach my $i (1, 2) {
729 # foreach with my under -p
742 foreach my $i (1, 2) {
747 foreach our $i (1, 2) {
751 # foreach with my and our
753 foreach our $i (1, 2) {
758 # CONTEXT use feature "state";
759 foreach state $i (1, 2) {
763 # foreach with sub call
764 foreach $_ (hcaerof()) {
770 print reverse sort(@x);
774 print((sort {$b cmp $a} @x));
776 # reverse sort with block
778 print((reverse sort {$b <=> $a} @x));
782 print $_ foreach (reverse @a);
784 # foreach reverse (not inplace)
786 print $_ foreach (reverse 1, 2..5);
790 @ary = split(' ', 'foo', 0);
793 @ary = split(' ', 'foo', 0);
796 our @array = split(//, 'foo', 0);
799 my @array = split(//, 'foo', 0);
803 @array = split(/x(?{ $c++; })y/, 'foo', 0);
807 ($x, $y) = split(/$p(?{ $c++; })y/, 'foo', 2);
811 @ary = split(/$pat/, 'foo', 0);
815 @ary = split(/$pat/, 'foo', 0);
819 local @array = split(/$pat/, 'foo', 0);
822 my @array = split(/$pat/, 'foo', 0);
828 do { my $x = 1; $x };
830 # <20061012113037.GJ25805@c4.convolution.nl>
849 sub foo {} foo & & & foo;
854 # variables as method names
857 'Foo'->$bar('orz') = 'a stranger stranger than before';
859 # constants as method names
862 # constants as method names without ()
865 # [perl #47359] "indirect" method call notation
869 foo{@bar}1 xor foo();
872 (foo { @bar } 1)->foo;
873 (foo { @bar } 1), foo();
874 foo { @bar } 1 xor foo();
876 # indirops with blocks
878 print {*STDOUT;} 'foo';
879 printf {*STDOUT;} 'foo';
880 say {*STDOUT;} 'foo';
881 system {'foo';} '-foo';
882 exec {'foo';} '-foo';
884 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
885 # CONTEXT use feature ':5.10';
889 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
890 # CONTEXT use 5.10.0;
891 # say in the context of use 5.10.0
894 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
895 # say with use 5.10.0
903 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
904 # say with use feature ':5.10';
908 use feature 'say', 'state', 'switch';
911 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
912 # CONTEXT use feature ':5.10';
913 # say with use 5.10.0 in the context of use feature
921 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
922 # CONTEXT use 5.10.0;
923 # say with use feature ':5.10' in the context of use 5.10.0
929 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
930 # CONTEXT use feature ':5.15';
934 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
935 # CONTEXT use 5.15.0;
936 # __SUB__ in the context of use 5.15.0
939 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
940 # __SUB__ with use 5.15.0
948 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
949 # __SUB__ with use feature ':5.15';
953 use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
956 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
957 # CONTEXT use feature ':5.15';
958 # __SUB__ with use 5.15.0 in the context of use feature
966 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
967 # CONTEXT use 5.15.0;
968 # __SUB__ with use feature ':5.15' in the context of use 5.15.0
974 # SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
975 # CONTEXT use feature ':5.10';
979 # SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
980 # CONTEXT use feature ':5.10';
981 # state var assignment
983 my $y = (state $x = 42);
986 # SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
987 # CONTEXT use feature ':5.10';
988 # state vars in anonymous subroutines
995 # SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
1000 # SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
1001 # keys @array; values @array
1002 keys @$a if keys @ARGV;
1003 values @ARGV if values @$a;
1005 # Anonymous arrays and hashes, and references to them
1011 # SKIP ?$] < 5.010 && "smartmatch and given/when not implemented on this Perl version"
1012 # CONTEXT use feature ':5.10'; no warnings 'experimental::smartmatch';
1013 # implicit smartmatch in given/when
1015 when ('bar') { continue; }
1016 when ($_ ~~ 'quux') { continue; }
1020 # conditions in elsifs (regression in change #33710 which fixed bug #37302)
1023 elsif ($a and $b) { x(); }
1024 elsif ($a or $b) { x(); }
1027 # interpolation in regexps
1031 # TODO new undocumented cpan-bug #33708
1035 # TODO hash constants not yet fixed
1037 use constant H => { "#" => 1 }; H->{"#"}
1039 # TODO optimized away 0 not yet fixed
1041 foreach my $i (@_) { 0 }
1043 # tests with not, not optimized
1046 x() if not $a and $b;
1047 x() if $a and not $b;
1048 x() unless not $a and $b;
1049 x() unless $a and not $b;
1050 x() if not $a or $b;
1051 x() if $a or not $b;
1052 x() unless not $a or $b;
1053 x() unless $a or not $b;
1054 x() if $a and not $b and $c;
1055 x() if not $a and $b and not $c;
1056 x() unless $a and not $b and $c;
1057 x() unless not $a and $b and not $c;
1058 x() if $a or not $b or $c;
1059 x() if not $a or $b or not $c;
1060 x() unless $a or not $b or $c;
1061 x() unless not $a or $b or not $c;
1063 # tests with not, optimized
1067 x() if not $a and not $b;
1068 x() unless not $a and not $b;
1069 x() if not $a or not $b;
1070 x() unless not $a or not $b;
1071 x() if not $a and not $b and $c;
1072 x() unless not $a and not $b and $c;
1073 x() if not $a or not $b or $c;
1074 x() unless not $a or not $b or $c;
1075 x() if not $a and not $b and not $c;
1076 x() unless not $a and not $b and not $c;
1077 x() if not $a or not $b or not $c;
1078 x() unless not $a or not $b or not $c;
1079 x() unless not $a or not $b or not $c;
1084 x() unless $a or $b;
1086 x() unless $a and $b;
1088 x() if not $a || $b and $c;
1089 x() unless not $a || $b and $c;
1090 x() if not $a && $b or $c;
1091 x() unless not $a && $b or $c;
1092 x() unless $a or $b or $c;
1093 x() if $a or $b or $c;
1094 x() unless $a and $b and $c;
1095 x() if $a and $b and $c;
1096 x() unless not $a && $b && $c;
1098 # tests that should be constant folded
1102 x() if GLIPP && GLIPP;
1103 x() if !GLIPP || GLIPP;
1104 x() if do { GLIPP };
1105 x() if do { no warnings 'void'; 5; GLIPP };
1106 x() if do { !GLIPP };
1107 if (GLIPP) { x() } else { z() }
1108 if (!GLIPP) { x() } else { z() }
1109 if (GLIPP) { x() } elsif (GLIPP) { z() }
1110 if (!GLIPP) { x() } elsif (GLIPP) { z() }
1111 if (GLIPP) { x() } elsif (!GLIPP) { z() }
1112 if (!GLIPP) { x() } elsif (!GLIPP) { z() }
1113 if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (GLIPP) { t() }
1114 if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
1115 if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
1149 # TODO constant deparsing has been backed out for 5.12
1150 # XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
1151 # tests that shouldn't be constant folded
1152 # It might be fundamentally impossible to make this work on ithreads, in which
1153 # case the TODO should become a SKIP
1155 if ($a == 1) { x() } elsif ($b == 2) { z() }
1156 if (do { foo(); GLIPP }) { x() }
1157 if (do { $a++; GLIPP }) { x() }
1160 if ($a == 1) { x(); } elsif ($b == 2) { z(); }
1161 if (do { foo(); GLIPP }) { x(); }
1162 if (do { ++$a; GLIPP }) { x(); }
1164 # TODO constant deparsing has been backed out for 5.12
1165 # tests for deparsing constants
1168 # TODO constant deparsing has been backed out for 5.12
1169 # tests for deparsing imported constants
1172 # TODO constant deparsing has been backed out for 5.12
1173 # tests for deparsing re-exported constants
1176 # TODO constant deparsing has been backed out for 5.12
1177 # tests for deparsing imported constants that got deleted from the original namespace
1180 # TODO constant deparsing has been backed out for 5.12
1181 # XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
1182 # tests for deparsing constants which got turned into full typeglobs
1183 # It might be fundamentally impossible to make this work on ithreads, in which
1184 # case the TODO should become a SKIP
1186 eval '@Fcntl::O_EXCL = qw/affe tiger/;';
1189 # TODO constant deparsing has been backed out for 5.12
1190 # tests for deparsing of blessed constant with overloaded numification
1191 warn OVERLOADED_NUMIFICATION;
1205 # TODO Subsets of warnings could be encoded textually, rather than as bitflips.
1206 # subsets of warnings
1207 no warnings 'deprecated';
1210 # TODO Better test for CPAN #33708 - the deparsed code has different behaviour
1226 # SKIP ?$] > 5.013006 && ":= is now a syntax error"
1227 # := treated as an empty attribute list
1234 # : = empty attribute list
1253 # #71870 Use of uninitialized value in bitwise and B::Deparse
1255 @a = split(/foo/, $s, 0);
1257 @a = split(/$r/, $s, 0);
1260 # package declaration before label
1266 # shift optimisation
1271 # shift optimisation
1274 # shift optimisation
1279 # shift optimisation
1283 "foo" =~ (1 ? /foo/ : /bar/);
1284 "foo" =~ (1 ? y/foo// : /bar/);
1285 "foo" =~ (1 ? y/foo//r : /bar/);
1286 "foo" =~ (1 ? s/foo// : /bar/);
1288 'foo' =~ ($_ =~ /foo/);
1289 'foo' =~ ($_ =~ tr/fo//);
1290 'foo' =~ ($_ =~ tr/fo//r);
1291 'foo' =~ ($_ =~ s/foo//);
1293 # The fix for [perl #20444] broke this.
1296 # [perl #81424] match against aelemfast_lex
1312 use constant QR_CONSTANT => qr/a/soupmix;
1321 # [perl #91318] /regexp/applaud
1322 print /a/a, s/b/c/a;
1323 print /a/aa, s/b/c/aa;
1324 print /a/p, s/b/c/p;
1325 print /a/l, s/b/c/l;
1326 print /a/u, s/b/c/u;
1328 use feature "unicode_strings";
1329 print /a/d, s/b/c/d;
1333 print /a/d, s/b/c/d;
1337 print /a/d, s/b/c/d;
1340 print /a/a, s/b/c/a;
1341 print /a/aa, s/b/c/aa;
1342 print /a/p, s/b/c/p;
1343 print /a/l, s/b/c/l;
1344 print /a/u, s/b/c/u;
1346 use feature 'unicode_strings';
1347 print /a/d, s/b/c/d;
1350 BEGIN { $^H{'reflags'} = '0';
1351 $^H{'reflags_charset'} = '2'; }
1352 print /a/d, s/b/c/d;
1356 use feature ':5.12';
1357 print /a/d, s/b/c/d;
1360 # all the flags (qr//)
1372 use feature 'unicode_strings';
1375 # all the flags (m//)
1389 use feature 'unicode_strings';
1392 # all the flags (s///)
1407 use feature 'unicode_strings';
1410 # all the flags (tr///)
1416 # [perl #119807] s//\(3)/ge should not warn when deparsed (\3 warns)
1420 "" =~ /a(?{ print q|
1423 '' =~ /a(?{ print "\n"; })/;
1426 $_ = qr/(??{<<END})/
1431 $_ = qr/(??{ "f.o\nb.r\n"; })/;
1433 # More regexp code block madness
1440 /a(??{ die $b; })a/;
1441 /$a(??{ die $b; })/;
1442 /@a(??{ die $b; })/;
1444 qr/a(?{ die $b; })a/;
1445 qr/$a(?{ die $b; })/;
1446 qr/@a(?{ die $b; })/;
1447 qr/(??{ die $b; })/;
1448 qr/a(??{ die $b; })a/;
1449 qr/$a(??{ die $b; })/;
1450 qr/@a(??{ die $b; })/;
1452 s/a(?{ die $b; })a//;
1453 s/$a(?{ die $b; })//;
1454 s/@a(?{ die $b; })//;
1455 s/(??{ die $b; })//;
1456 s/a(??{ die $b; })a//;
1457 s/$a(??{ die $b; })//;
1458 s/@a(??{ die $b; })//;
1460 # /(?x)<newline><tab>/
1465 tr/a/b/r + $a =~ tr/p/q/r;
1467 # y///d in list [perl #119815]
1478 # SKIP ?$] >= 5.023 && "autoderef deleted in this Perl version"
1479 # CONTEXT no warnings 'experimental::autoderef';
1484 # readpipe with complex expression
1490 # aelemfast for a lexical
1494 # feature features without feature
1495 # CONTEXT no warnings 'experimental::smartmatch';
1510 # feature features when feature has been disabled by use VERSION
1511 # CONTEXT no warnings 'experimental::smartmatch';
1512 use feature (sprintf(":%vd", $^V));
1540 # (the above test with CONTEXT, and the output is equivalent but different)
1541 # CONTEXT use feature ':5.10'; no warnings 'experimental::smartmatch';
1542 # feature features when feature has been disabled by use VERSION
1543 use feature (sprintf(":%vd", $^V));
1559 use feature ':default';
1573 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
1574 # lexical subroutines and keywords of the same name
1575 # CONTEXT use feature 'lexical_subs', 'switch'; no warnings 'experimental';
1599 CORE::default { die; }
1600 CORE::if ($1) { die; }
1601 CORE::if ($1) { die; }
1602 CORE::elsif ($1) { die; }
1604 CORE::for (die; $1; die) { die; }
1605 CORE::foreach $_ (1 .. 10) { die; }
1606 die CORE::foreach (1);
1607 CORE::given ($1) { die; }
1612 () = (CORE::q['], CORE::qq["$_], CORE::qr//, CORE::qx[`]);
1615 () = CORE::sub { die; } ;
1617 CORE::unless ($1) { die; }
1618 CORE::until ($1) { die; }
1621 CORE::when ($1 ~~ $2) { die; }
1622 CORE::while ($1) { die; }
1626 use feature 'current_sub', 'evalbytes';
1632 no feature 'unicode_strings';
1635 use feature 'current_sub', 'evalbytes';
1638 use feature ':default';
1641 use feature ':5.12';
1643 no feature 'unicode_strings';
1646 # $#- $#+ $#{%} etc.
1648 @x = ($#{`}, $#{~}, $#{!}, $#{@}, $#{$}, $#{%}, $#{^}, $#{&}, $#{*});
1649 @x = ($#{(}, $#{)}, $#{[}, $#{{}, $#{]}, $#{}}, $#{'}, $#{"}, $#{,});
1650 @x = ($#{<}, $#{.}, $#{>}, $#{/}, $#{?}, $#{=}, $#+, $#{\}, $#{|}, $#-);
1651 @x = ($#{;}, $#{:}, $#{1}), $#_;
1654 # It's a known TODO that warnings are deparsed as bits, not textually.
1658 # [perl #86060] $( $| $) in regexps need braces
1669 # sort(foo(bar)) is interpreted as sort &foo(bar)
1670 # sort foo(bar) is interpreted as sort foo bar
1671 # parentheses are not optional in this case
1672 print sort(foo('bar'));
1674 print sort(foo('bar'));
1677 substr(my $a, 0, 0) = (foo(), bar());
1680 # This following line works around an unfixed bug that we are not trying to
1682 # CONTEXT BEGIN { $^H{a} = "b"; delete $^H{a} } # make %^H localised
1684 BEGIN { $^H{'foo'} = undef; }
1686 BEGIN { $^H{'bar'} = undef; }
1688 BEGIN { $^H{'baz'} = undef; }
1696 BEGIN { $^H{q[']} = '('; }
1699 # This following line works around an unfixed bug that we are not trying to
1701 # CONTEXT BEGIN { $^H{a} = "b"; delete $^H{a} } # make %^H localised
1702 # hint hash changes that serialise the same way with sort %hh
1703 BEGIN { $^H{'a'} = 'b'; }
1705 BEGIN { $^H{'b'} = 'a'; delete $^H{'a'}; }
1710 # [perl #47361] do({}) and do +{} (variants of do-file)
1724 # [perl #77096] functions that do not follow the llafr
1725 () = (return 1) + time;
1726 () = (return ($1 + $2) * $3) + time;
1727 () = (return ($a xor $b)) + time;
1728 () = (do 'file') + time;
1729 () = (do ($1 + $2) * $3) + time;
1730 () = (do ($1 xor $2)) + time;
1732 () = (require 'foo') + 3;
1733 () = (require foo) + 3;
1734 () = (CORE::dump 1) + 3;
1745 # require(foo()) and do(foo())
1757 # [perl #97476] not() *does* follow the llafr
1758 $_ = ($a xor not +($1 || 2) ** 2);
1760 # Precedence conundrums with argument-less function calls
1768 # loopexes have assignment prec
1769 () = (CORE::dump a) | 'b';
1770 () = (goto a) | 'b';
1771 () = (last a) | 'b';
1772 () = (next a) | 'b';
1773 () = (redo a) | 'b';
1775 # [perl #63558] open local(*FH)
1777 pipe local *FH, local *FH;
1779 # [perl #91416] open "string"
1792 () = 'open'->[0]; #aelemfast
1797 () = 'open'->[$_]; #aelem
1802 () = 'open'->{0}; #helem
1823 () = 'a::]b'->{'0'};
1825 # [perl #74740] -(f()) vs -f()
1831 #[perl #30504] foreach-my postfix/prefix difference
1832 $_ = 'foo' foreach my ($foo1, $bar1, $baz1);
1833 foreach (my ($foo2, $bar2, $baz2)) { $_ = 'foo' }
1834 foreach my $i (my ($foo3, $bar3, $baz3)) { $i = 'foo' }
1836 $_ = 'foo' foreach (my($foo1, $bar1, $baz1));
1837 foreach $_ (my($foo2, $bar2, $baz2)) {
1840 foreach my $i (my($foo3, $bar3, $baz3)) {
1844 #[perl #108224] foreach with continue block
1845 foreach (1 .. 3) { print } continue { print "\n" }
1846 foreach (1 .. 3) { } continue { }
1847 foreach my $i (1 .. 3) { print $i } continue { print "\n" }
1848 foreach my $i (1 .. 3) { } continue { }
1850 foreach $_ (1 .. 3) {
1856 foreach $_ (1 .. 3) {
1862 foreach my $i (1 .. 3) {
1868 foreach my $i (1 .. 3) {
1889 # 'my' works with padrange op
1896 ($m3, $m4) = (1, 2);
1898 my($m5, $m6) = (1, 2);
1899 my($m7, undef, $m8) = (1, 2, 3);
1900 @z = ($m7, undef, $m8);
1901 ($m7, undef, $m8) = (1, 2, 3);
1903 # 'our/local' works with padrange op
1914 ($o3, $o4) = (1, 2);
1915 local($o3, $o4) = (1, 2);
1917 @z = local($o3, $o4);
1918 our($o5, $o6) = (1, 2);
1919 our($o7, undef, $o8) = (1, 2, 3);
1920 @z = ($o7, undef, $o8);
1921 @z = local($o7, undef, $o8);
1922 ($o7, undef, $o8) = (1, 2, 3);
1923 local($o7, undef, $o8) = (1, 2, 3);
1925 # 'state' works with padrange op
1926 # CONTEXT no strict; use feature 'state';
1933 ($s3, $s4) = (1, 2);
1935 # assignment of state lists isn't implemented yet
1936 #state($s5, $s6) = (1, 2);
1937 #state($s7, undef, $s8) = (1, 2, 3);
1938 #@z = ($s7, undef, $s8);
1939 ($s7, undef, $s8) = (1, 2, 3);
1941 # anon arrays with padrange
1946 # slices with padrange
1952 # binops with padrange
1966 my($a, $b, $c, $d, @e);
1971 @e = ($a, $b, $c) x $d;
1975 my($a, $b, $c) = @_;
1977 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
1978 # lexical subroutine
1979 # CONTEXT use feature 'lexical_subs';
1980 no warnings "experimental::lexical_subs";
1984 BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55"}
1990 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
1991 # lexical "state" subroutine
1992 # CONTEXT use feature 'state', 'lexical_subs';
1993 no warnings 'experimental::lexical_subs';
1997 BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55"}
2003 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
2004 # lexical subroutine scoping
2005 # CONTEXT use feature 'lexical_subs'; no warnings 'experimental::lexical_subs';
2023 # self-referential lexical subroutine
2024 # CONTEXT use feature 'lexical_subs', 'state'; no warnings 'experimental::lexical_subs';
2031 # lexical subroutine with outer declaration and inner definition
2032 # CONTEXT use feature 'lexical_subs'; no warnings 'experimental::lexical_subs';
2040 # TODO only partially fixed
2041 # lexical state subroutine with outer declaration and inner definition
2042 # CONTEXT use feature 'lexical_subs', 'state'; no warnings 'experimental::lexical_subs';
2055 # Elements of %# should not be confused with $#{ array }
2064 # Ampersand calls and scalar context
2071 &foo(scalar bar(), scalar baz());
2073 # coderef2text and prototyped sub calls [perl #123435]
2076 # prototypes with unary precedence
2079 sub optdollar(;$) {}
2080 sub optoptdollar(;;$) {}
2083 sub optoptsplat(;;*) {}
2086 sub optoptbar(;;_) {}
2089 sub optoptplus(;;+) {}
2092 sub optoptwack(;;\$) {}
2093 sub wackbrack(\[$]) {}
2094 sub optwackbrack(;\[$]) {}
2095 sub optoptwackbrack(;;\[$]) {}
2098 optoptdollar($a < $b);
2099 splat($a < $b); # Some of these deparse with ‘&’; if that changes, just
2100 optsplat($a < $b); # change the tests.
2101 optoptsplat($a < $b);
2107 optoptplus($a < $b);
2110 optoptwack($a = $b);
2112 optwackbrack($a = $b);
2113 optoptwackbrack($a = $b);
2118 optoptdollar($a < $b);
2121 &optoptsplat($a < $b);
2127 &optoptplus($a < $b);
2129 &optwack(\($a = $b));
2130 &optoptwack(\($a = $b));
2131 &wackbrack(\($a = $b));
2132 &optwackbrack(\($a = $b));
2133 &optoptwackbrack(\($a = $b));
2135 # ensure aelemfast works in the range -128..127 and that there's no
2139 $x = $a[-256] + $a[-255] + $a[-129] + $a[-128] + $a[-127] + $a[-1] + $a[0];
2140 $x = $a[1] + $a[126] + $a[127] + $a[128] + $a[255] + $a[256];
2142 $x = $b[-256] + $b[-255] + $b[-129] + $b[-128] + $b[-127] + $b[-1] + $b[0];
2143 $x = $b[1] + $b[126] + $b[127] + $b[128] + $b[255] + $b[256];
2145 # 'm' must be preserved in m??
2148 # \(@array) and \(..., (@array), ...)
2149 my(@array, %hash, @a, @b, %c, %d);
2152 () = \(@a, (@b), (%c), %d);
2153 () = \(@Foo::array);
2155 () = \(@Foo::a, (@Foo::b), (%Foo::c), %Foo::d);
2157 # subs synonymous with keywords
2161 use feature 'state';
2165 # CONTEXT use feature "state", 'refaliasing', 'lexical_subs'; no warnings 'experimental';
2177 \($x, my $a) = @{[\$x, \$x]};
2178 (\$x, \my $b) = @{[\$x, \$x]};
2190 \local($a[1]) = foo();
2193 \local @a[0,1] = (\$a)x2;
2200 \local($h{b}) = \$x;
2201 \@h{'a','b'} = foo();
2203 \local @h{'a','b'} = (\$x)x2;
2239 (\$_, $_) = \(1, 2);
2240 $_ == 3 ? \$_ : $_ = \3;
2241 $_ == 3 ? \$_ : \$x = \3;
2242 \($_ == 3 ? $_ : $x) = \3;
2243 for \my $topic (\$1, \$2) {
2246 for \state $topic (\$1, \$2) {
2249 for \our $topic (\$1, \$2) {
2252 for \$_ (\$1, \$2) {
2255 for \my @a ([1,2], [3,4]) {
2258 for \state @a ([1,2], [3,4]) {
2261 for \our @a ([1,2], [3,4]) {
2264 for \@_ ([1,2], [3,4]) {
2267 for \my %a ({5,6}, {7,8}) {
2270 for \our %a ({5,6}, {7,8}) {
2273 for \state %a ({5,6}, {7,8}) {
2276 for \%_ ({5,6}, {7,8}) {
2281 for \&a (sub { 9; }, sub { 10; }) {
2285 for \&a (sub { 9; }, sub { 10; }) {
2300 (\$x, \my $a) = @{[\$x, \$x];};
2301 (\$x, \my $b) = @{[\$x, \$x];};
2313 (\local $a[1]) = foo();
2314 (\@a[0, 1]) = foo();
2315 (\@a[2, 3]) = foo();
2316 (\local @a[0, 1]) = (\$a) x 2;
2322 \local $h{'a'} = \$x;
2323 (\local $h{'b'}) = \$x;
2324 (\@h{'a', 'b'}) = foo();
2325 (\@h{2, 3}) = foo();
2326 (\local @h{'a', 'b'}) = (\$x) x 2;
2352 (\our %zz) = {1, 2};
2362 (\$_, $_) = \(1, 2);
2363 $_ == 3 ? \$_ : $_ = \3;
2364 $_ == 3 ? \$_ : \$x = \3;
2365 ($_ == 3 ? \$_ : \$x) = \3;
2366 foreach \my $topic (\$1, \$2) {
2369 foreach \state $topic (\$1, \$2) {
2372 foreach \our $topic (\$1, \$2) {
2375 foreach \$_ (\$1, \$2) {
2378 foreach \my @a ([1, 2], [3, 4]) {
2381 foreach \state @a ([1, 2], [3, 4]) {
2384 foreach \our @a ([1, 2], [3, 4]) {
2387 foreach \@_ ([1, 2], [3, 4]) {
2390 foreach \my %a ({5, 6}, {7, 8}) {
2393 foreach \our %a ({5, 6}, {7, 8}) {
2396 foreach \state %a ({5, 6}, {7, 8}) {
2399 foreach \%_ ({5, 6}, {7, 8}) {
2404 foreach \&a (sub { 9; } , sub { 10; } ) {
2408 foreach \&a (sub { 9; } , sub { 10; } ) {
2417 $_ = join('???', pos $_);
2423 # my @a; exists $a[0]
2431 # my @a; delete $a[0]
2446 # my $x = "$h{foo}";
2448 my $x = "$h{'foo'}";
2450 # weird constant hash key
2452 my $x = $h{"\000\t\x{100}"};
2454 # multideref and packages
2456 my(%bar) = ('a', 'b');
2458 $bar{'k'} = $bar[200];
2459 $main::bar{'k'} = $main::bar[200];
2460 $foo::bar{'k'} = $foo::bar[200];
2462 $bar{'k'} = $bar[200];
2463 $main::bar{'k'} = $main::bar[200];
2464 $foo::bar{'k'} = $foo::bar[200];
2467 my(%bar) = ('a', 'b');
2469 $bar{'k'} = $bar[200];
2470 $main::bar{'k'} = $main::bar[200];
2471 $foo::bar{'k'} = $bar[200];
2473 $bar{'k'} = $foo::bar[200];
2474 $main::bar{'k'} = $main::bar[200];
2475 $foo::bar{'k'} = $foo::bar[200];
2477 # multideref and local
2479 local $h{'foo'}[0] = 1;
2481 # multideref and exists
2483 my $e = exists $h{'foo'}[$i];
2485 # multideref and delete
2487 my $e = delete $h{'foo'}[$i];
2489 # multideref with leading expression
2491 my $x = +($r // [])->{'foo'}[0];
2493 # multideref with complex middle index
2495 my $x = $h{'foo'}[$i + $j]{$k};
2497 # multideref with trailing non-simple index that initially looks simple
2498 # (i.e. the constant "3")
2500 my $x = +($r || {})->{'foo'}[$i + $j]{3 + $k};
2508 # CONTEXT use feature "bitwise"; no warnings "experimental::bitwise";
2525 # Should really use 'no warnings "experimental::signatures"',
2526 # but it doesn't yet deparse correctly.
2527 # anon subs used because this test framework doesn't deparse named subs
2528 # in the DATA code snippets.
2532 use feature 'signatures';
2534 sub ($a, $, $b = $glo::bal, $c = $a, $d = 'foo', $e = -37, $f = 0, $g = 1, $h = undef, $i = $a + 1, $j = /foo/, @) {
2540 # Signature and prototype
2542 use feature 'signatures';
2544 sub ($a, $b) : prototype($$) {
2550 # Signature and prototype and attrs
2552 use feature 'signatures';
2554 sub ($a, $b) : prototype($$) lvalue {
2560 # Signature and attrs
2562 use feature 'signatures';
2564 sub ($a, $b) : lvalue method {
2570 # named array slurp, null body
2572 use feature 'signatures';
2580 use feature 'signatures';
2588 use feature 'signatures';
2594 # parenthesised default arg
2596 use feature 'signatures';
2597 sub ($a, $b = (/foo/), $c = 1) {
2602 # parenthesised default arg with TARGMY
2604 use feature 'signatures';
2605 sub ($a, $b = ($a + 1), $c = 1) {
2612 use feature 'signatures';
2618 # padrange op within pattern code blocks
2619 /(?{ my($x, $y) = (); })/;
2621 /$a(?{ my($x, $y) = (); })/;
2622 my $r1 = qr/(?{ my($x, $y) = (); })/;
2623 my $r2 = qr/$a(?{ my($x, $y) = (); })/;
2625 # don't remove pattern whitespace escapes
2632 my $s1 :foo(f1, f2) bar(b1, b2);
2633 my @a1 :foo(f1, f2) bar(b1, b2);
2634 my %h1 :foo(f1, f2) bar(b1, b2);
2635 my($s2, @a2, %h2) :foo(f1, f2) bar(b1, b2);
2637 # my class attributes
2639 my Foo::Bar $s1 :foo(f1, f2) bar(b1, b2);
2640 my Foo::Bar @a1 :foo(f1, f2) bar(b1, b2);
2641 my Foo::Bar %h1 :foo(f1, f2) bar(b1, b2);
2642 my Foo::Bar ($s2, @a2, %h2) :foo(f1, f2) bar(b1, b2);
2644 my Foo::Bar $s3 :foo(f1, f2) bar(b1, b2);
2645 my Foo::Bar @a3 :foo(f1, f2) bar(b1, b2);
2646 my Foo::Bar %h3 :foo(f1, f2) bar(b1, b2);
2647 my Foo::Bar ($s4, @a4, %h4) :foo(f1, f2) bar(b1, b2);
2649 # avoid false positives in my $x :attribute
2650 'attributes'->import('main', \my $x1, 'foo(bar)'), my $y1;
2651 'attributes'->import('Fooo', \my $x2, 'foo(bar)'), my $y2;
2653 # hash slices and hash key/value slices
2656 @a = @h{'foo', 'bar'};
2657 @a = %h{'foo', 'bar'};
2658 @a = delete @h{'foo', 'bar'};
2659 @a = delete %h{'foo', 'bar'};
2660 @oa = @oh{'foo', 'bar'};
2661 @oa = %oh{'foo', 'bar'};
2662 @oa = delete @oh{'foo', 'bar'};
2663 @oa = delete %oh{'foo', 'bar'};
2665 # keys optimised away in void and scalar context
2679 # eq,const optimised away for (index() == -1)
2682 $c = index($a, $b) == 2;
2683 $c = rindex($a, $b) == 2;
2684 $c = index($a, $b) == -1;
2685 $c = rindex($a, $b) == -1;
2686 $c = index($a, $b) != -1;
2687 $c = rindex($a, $b) != -1;
2688 $c = (index($a, $b) == -1);
2689 $c = (rindex($a, $b) == -1);
2690 $c = (index($a, $b) != -1);
2691 $c = (rindex($a, $b) != -1);
2693 # eq,const,sassign,madmy optimised away for (index() == -1)
2696 $c = index($a, $b) == 2;
2697 $c = rindex($a, $b) == 2;
2698 $c = index($a, $b) == -1;
2699 $c = rindex($a, $b) == -1;
2700 $c = index($a, $b) != -1;
2701 $c = rindex($a, $b) != -1;
2702 $c = (index($a, $b) == -1);
2703 $c = (rindex($a, $b) == -1);
2704 $c = (index($a, $b) != -1);
2705 $c = (rindex($a, $b) != -1);