This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
op.h: Corrent comment about entersub strictures
[perl5.git] / dist / B-Deparse / t / deparse.t
CommitLineData
87a42246
MS
1#!./perl
2
3BEGIN {
62a6bb71 4 unshift @INC, 't';
9cd8f857
NC
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 }
87a42246
MS
10}
11
87a42246
MS
12use warnings;
13use strict;
507a68aa 14use Test::More;
87a42246 15
93a8ff62 16my $tests = 18; # not counting those in the __DATA__ section
3036b99c 17
87a42246 18use B::Deparse;
09d856fb 19my $deparse = B::Deparse->new();
507a68aa 20isa_ok($deparse, 'B::Deparse', 'instantiate a B::Deparse object');
4da9a2ca 21my %deparse;
87a42246 22
ad46c0be
RH
23$/ = "\n####\n";
24while (<DATA>) {
25 chomp;
d8cf01c3 26 $tests ++;
e9c69003
NC
27 # This code is pinched from the t/lib/common.pl for TODO.
28 # It's not clear how to avoid duplication
a6087f24 29 my %meta = (context => '');
4da9a2ca 30 foreach my $what (qw(skip todo context options)) {
c4a350e6 31 s/^#\s*\U$what\E\s*(.*)\n//m and $meta{$what} = $1;
b871937f
NC
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
c4a350e6
NC
34 if ($meta{$what} && $meta{$what} =~ s/^\?//) {
35 my $temp = eval $meta{$what};
b871937f 36 if ($@) {
c4a350e6 37 die "# In \U$what\E code reason:\n# $meta{$what}\n$@";
b871937f 38 }
c4a350e6 39 $meta{$what} = $temp;
e9c69003 40 }
e9c69003
NC
41 }
42
4a4b8592 43 s/^\s*#\s*(.*)$//mg;
507a68aa
NC
44 my $desc = $1;
45 die "Missing name in test $_" unless defined $desc;
e9c69003 46
c4a350e6 47 if ($meta{skip}) {
e9c69003 48 # Like this to avoid needing a label SKIP:
c4a350e6 49 Test::More->builder->skip($meta{skip});
e9c69003
NC
50 next;
51 }
52
ad46c0be
RH
53 my ($input, $expected);
54 if (/(.*)\n>>>>\n(.*)/s) {
55 ($input, $expected) = ($1, $2);
56 }
57 else {
58 ($input, $expected) = ($_, $_);
59 }
87a42246 60
4da9a2ca
FC
61 # parse options if necessary
62 my $deparse = $meta{options}
63 ? $deparse{$meta{options}} ||=
64 new B::Deparse split /,/, $meta{options}
65 : $deparse;
66
a6087f24
NC
67 my $coderef = eval "$meta{context};\n" . <<'EOC' . "sub {$input}";
68# Tell B::Deparse about our ambient pragmas
69my ($hint_bits, $warning_bits, $hinthash);
70BEGIN {
71 ($hint_bits, $warning_bits, $hinthash) = ($^H, ${^WARNING_BITS}, \%^H);
72}
73$deparse->ambient_pragmas (
74 hint_bits => $hint_bits,
75 warning_bits => $warning_bits,
76 '%^H' => $hinthash,
77);
78EOC
87a42246 79
ad46c0be 80 if ($@) {
507a68aa 81 is($@, "", "compilation of $desc");
ad46c0be
RH
82 }
83 else {
84 my $deparsed = $deparse->coderef2text( $coderef );
31c6271a
RD
85 my $regex = $expected;
86 $regex =~ s/(\S+)/\Q$1/g;
87 $regex =~ s/\s+/\\s+/g;
88 $regex = '^\{\s*' . $regex . '\s*\}$';
b871937f 89
c4a350e6 90 local $::TODO = $meta{todo};
507a68aa 91 like($deparsed, qr/$regex/, $desc);
87a42246 92 }
87a42246
MS
93}
94
87a42246 95use constant 'c', 'stuff';
507a68aa
NC
96is((eval "sub ".$deparse->coderef2text(\&c))->(), 'stuff',
97 'the subroutine generated by use constant deparses');
87a42246 98
09d856fb 99my $a = 0;
507a68aa
NC
100is($deparse->coderef2text(sub{(-1) ** $a }), "{\n (-1) ** \$a;\n}",
101 'anon sub capturing an external lexical');
87a42246 102
d989cdac
SM
103use constant cr => ['hello'];
104my $string = "sub " . $deparse->coderef2text(\&cr);
0707d6cc 105my $val = (eval $string)->() or diag $string;
507a68aa
NC
106is(ref($val), 'ARRAY', 'constant array references deparse');
107is($val->[0], 'hello', 'and return the correct value');
87a42246 108
87a42246 109my $path = join " ", map { qq["-I$_"] } @INC;
87a42246 110
7cde0a5f 111$a = `$^X $path "-MO=Deparse" -anlwi.bak -e 1 2>&1`;
e69a2255 112$a =~ s/-e syntax OK\n//g;
d2bc402e 113$a =~ s/.*possible typo.*\n//; # Remove warning line
82f96200 114$a =~ s/.*-i used with no filenames.*\n//; # Remove warning line
87a42246
MS
115$a =~ s{\\340\\242}{\\s} if (ord("\\") == 224); # EBCDIC, cp 1047 or 037
116$a =~ s{\\274\\242}{\\s} if (ord("\\") == 188); # $^O eq 'posix-bc'
117$b = <<'EOF';
d2bc402e
RGS
118BEGIN { $^I = ".bak"; }
119BEGIN { $^W = 1; }
120BEGIN { $/ = "\n"; $\ = "\n"; }
87a42246
MS
121LINE: while (defined($_ = <ARGV>)) {
122 chomp $_;
f86ea535 123 our(@F) = split(' ', $_, 0);
87a42246
MS
124 '???';
125}
87a42246 126EOF
507a68aa
NC
127is($a, $b,
128 'command line flags deparse as BEGIN blocks setting control variables');
87a42246 129
5b4ee549
NC
130$a = `$^X $path "-MO=Deparse" -e "use constant PI => 4" 2>&1`;
131$a =~ s/-e syntax OK\n//g;
132is($a, "use constant ('PI', 4);\n",
133 "Proxy Constant Subroutines must not show up as (incorrect) prototypes");
134
579a54dc 135#Re: perlbug #35857, patch #24505
b3980c39
YO
136#handle warnings::register-ed packages properly.
137package B::Deparse::Wrapper;
138use strict;
139use warnings;
140use warnings::register;
141sub getcode {
579a54dc 142 my $deparser = B::Deparse->new();
b3980c39
YO
143 return $deparser->coderef2text(shift);
144}
145
2990415a
FR
146package Moo;
147use overload '0+' => sub { 42 };
148
b3980c39
YO
149package main;
150use strict;
151use warnings;
71c4dbc3 152use constant GLIPP => 'glipp';
2990415a
FR
153use constant PI => 4;
154use constant OVERLOADED_NUMIFICATION => bless({}, 'Moo');
3779476a 155use Fcntl qw/O_TRUNC O_APPEND O_EXCL/;
aaf9c2b2 156BEGIN { delete $::Fcntl::{O_APPEND}; }
2990415a 157use POSIX qw/O_CREAT/;
b3980c39 158sub test {
579a54dc
RGS
159 my $val = shift;
160 my $res = B::Deparse::Wrapper::getcode($val);
507a68aa
NC
161 like($res, qr/use warnings/,
162 '[perl #35857] [PATCH] B::Deparse doesnt handle warnings register properly');
b3980c39
YO
163}
164my ($q,$p);
165my $x=sub { ++$q,++$p };
166test($x);
167eval <<EOFCODE and test($x);
168 package bar;
169 use strict;
170 use warnings;
171 use warnings::register;
172 package main;
173 1
174EOFCODE
175
d1dc589d
FC
176# Exotic sub declarations
177$a = `$^X $path "-MO=Deparse" -e "sub ::::{}sub ::::::{}" 2>&1`;
178$a =~ s/-e syntax OK\n//g;
179is($a, <<'EOCODG', "sub :::: and sub ::::::");
180sub :::: {
181
182}
183sub :::::: {
184
185}
186EOCODG
187
640d5d41
FC
188# [perl #33752]
189{
190 my $code = <<"EOCODE";
191{
192 our \$\x{1e1f}\x{14d}\x{14d};
193}
194EOCODE
195 my $deparsed
196 = $deparse->coderef2text(eval "sub { our \$\x{1e1f}\x{14d}\x{14d} }" );
197 s/$ \n//x for $deparsed, $code;
198 is $deparsed, $code, 'our $funny_Unicode_chars';
199}
200
bdabb2d5
FC
201# [perl #62500]
202$a =
203 `$^X $path "-MO=Deparse" -e "BEGIN{*CORE::GLOBAL::require=sub{1}}" 2>&1`;
204$a =~ s/-e syntax OK\n//g;
205is($a, <<'EOCODF', "CORE::GLOBAL::require override causing panick");
206sub BEGIN {
207 *CORE::GLOBAL::require = sub {
208 1;
209 }
210 ;
211}
212EOCODF
213
894e98ac
FC
214# [perl #91384]
215$a =
216 `$^X $path "-MO=Deparse" -e "BEGIN{*Acme::Acme:: = *Acme::}" 2>&1`;
217like($a, qr/-e syntax OK/,
218 "Deparse does not hang when traversing stash circularities");
219
bb8996b8 220# [perl #93990]
08412a26
NC
221@] = ();
222is($deparse->coderef2text(sub{ print "@{]}" }),
bb8996b8 223q<{
08412a26
NC
224 print "@{]}";
225}>, 'curly around to interpolate "@{]}"');
bb8996b8
HY
226is($deparse->coderef2text(sub{ print "@{-}" }),
227q<{
228 print "@-";
229}>, 'no need to curly around to interpolate "@-"');
230
1c74777c
FC
231# Strict hints in %^H are mercilessly suppressed
232$a =
233 `$^X $path "-MO=Deparse" -e "use strict; print;" 2>&1`;
234unlike($a, qr/BEGIN/,
235 "Deparse does not emit strict hh hints");
236
3036b99c
FC
237# ambient_pragmas should not mess with strict settings.
238SKIP: {
239 skip "requires 5.11", 1 unless $] >= 5.011;
240 eval q`
3036b99c 241 BEGIN {
d1718a7c 242 # Clear out all hints
3036b99c 243 %^H = ();
d1718a7c 244 $^H = 0;
3036b99c
FC
245 new B::Deparse -> ambient_pragmas(strict => 'all');
246 }
247 use 5.011; # should enable strict
248 ok !eval '$do_noT_create_a_variable_with_this_name = 1',
249 'ambient_pragmas do not mess with compiling scope';
250 `;
251}
252
93a8ff62
FC
253# multiple statements on format lines
254$a = `$^X $path "-MO=Deparse" -e "format =" -e "\@" -e "x();z()" -e. 2>&1`;
255$a =~ s/-e syntax OK\n//g;
93a8ff62
FC
256is($a, <<'EOCODH', 'multiple statements on format lines');
257format STDOUT =
258@
259x(); z()
260.
261EOCODH
262
263
d8cf01c3 264done_testing($tests);
507a68aa 265
ad46c0be 266__DATA__
507a68aa 267# A constant
ad46c0be
RH
2681;
269####
507a68aa 270# Constants in a block
ad46c0be
RH
271{
272 no warnings;
273 '???';
274 2;
275}
276####
507a68aa 277# Lexical and simple arithmetic
ad46c0be
RH
278my $test;
279++$test and $test /= 2;
280>>>>
281my $test;
282$test /= 2 if ++$test;
283####
507a68aa 284# list x
ad46c0be
RH
285-((1, 2) x 2);
286####
507a68aa 287# lvalue sub
ad46c0be
RH
288{
289 my $test = sub : lvalue {
290 my $x;
291 }
292 ;
293}
294####
507a68aa 295# method
ad46c0be
RH
296{
297 my $test = sub : method {
298 my $x;
299 }
300 ;
301}
302####
507a68aa 303# block with continue
87a42246 304{
ad46c0be 305 234;
f99a63a2 306}
ad46c0be
RH
307continue {
308 123;
87a42246 309}
ce4e655d 310####
507a68aa 311# lexical and package scalars
ce4e655d
RH
312my $x;
313print $main::x;
314####
507a68aa 315# lexical and package arrays
ce4e655d
RH
316my @x;
317print $main::x[1];
14a55f98 318####
507a68aa 319# lexical and package hashes
14a55f98
RH
320my %x;
321$x{warn()};
ad8caead 322####
507a68aa 323# <>
ad8caead
RGS
324my $foo;
325$_ .= <ARGV> . <$foo>;
cef22867 326####
507a68aa 327# \x{}
11454c59 328my $foo = "Ab\x{100}\200\x{200}\237Cd\000Ef\x{1000}\cA\x{2000}\cZ";
4ae52e81 329####
507a68aa 330# s///e
4ae52e81 331s/x/'y';/e;
ef90d20a
FC
332s/x/$a;/e;
333s/x/complex_expression();/e;
241416b8 334####
507a68aa 335# block
241416b8
DM
336{ my $x; }
337####
507a68aa 338# while 1
241416b8
DM
339while (1) { my $k; }
340####
507a68aa 341# trailing for
241416b8
DM
342my ($x,@a);
343$x=1 for @a;
344>>>>
345my($x, @a);
0bb5f065 346$x = 1 foreach (@a);
241416b8 347####
507a68aa 348# 2 arguments in a 3 argument for
241416b8
DM
349for (my $i = 0; $i < 2;) {
350 my $z = 1;
351}
352####
507a68aa 353# 3 argument for
241416b8
DM
354for (my $i = 0; $i < 2; ++$i) {
355 my $z = 1;
356}
357####
507a68aa 358# 3 argument for again
241416b8
DM
359for (my $i = 0; $i < 2; ++$i) {
360 my $z = 1;
361}
362####
507a68aa 363# while/continue
241416b8
DM
364my $i;
365while ($i) { my $z = 1; } continue { $i = 99; }
366####
507a68aa 367# foreach with my
09d856fb 368foreach my $i (1, 2) {
241416b8
DM
369 my $z = 1;
370}
371####
4da9a2ca
FC
372# OPTIONS -p
373# foreach with my under -p
374foreach my $i (1) {
375 die;
376}
377####
507a68aa 378# foreach
241416b8
DM
379my $i;
380foreach $i (1, 2) {
381 my $z = 1;
382}
383####
507a68aa 384# foreach, 2 mys
241416b8
DM
385my $i;
386foreach my $i (1, 2) {
387 my $z = 1;
388}
389####
507a68aa 390# foreach
241416b8
DM
391foreach my $i (1, 2) {
392 my $z = 1;
393}
394####
507a68aa 395# foreach with our
241416b8
DM
396foreach our $i (1, 2) {
397 my $z = 1;
398}
399####
507a68aa 400# foreach with my and our
241416b8
DM
401my $i;
402foreach our $i (1, 2) {
403 my $z = 1;
404}
3ac6e0f9 405####
507a68aa 406# reverse sort
3ac6e0f9
RGS
407my @x;
408print reverse sort(@x);
409####
507a68aa 410# sort with cmp
3ac6e0f9
RGS
411my @x;
412print((sort {$b cmp $a} @x));
413####
507a68aa 414# reverse sort with block
3ac6e0f9
RGS
415my @x;
416print((reverse sort {$b <=> $a} @x));
36d57d93 417####
507a68aa 418# foreach reverse
36d57d93
RGS
419our @a;
420print $_ foreach (reverse @a);
aae53c41 421####
507a68aa 422# foreach reverse (not inplace)
aae53c41
RGS
423our @a;
424print $_ foreach (reverse 1, 2..5);
f86ea535 425####
507a68aa 426# bug #38684
f86ea535
SM
427our @ary;
428@ary = split(' ', 'foo', 0);
31c6271a 429####
507a68aa 430# bug #40055
31c6271a
RD
431do { () };
432####
507a68aa 433# bug #40055
31c6271a 434do { my $x = 1; $x };
d9002312 435####
507a68aa 436# <20061012113037.GJ25805@c4.convolution.nl>
d9002312
SM
437my $f = sub {
438 +{[]};
439} ;
8b2d6640 440####
507a68aa 441# bug #43010
8b2d6640
FC
442'!@$%'->();
443####
507a68aa 444# bug #43010
8b2d6640
FC
445::();
446####
507a68aa 447# bug #43010
8b2d6640
FC
448'::::'->();
449####
507a68aa 450# bug #43010
8b2d6640 451&::::;
09d856fb 452####
1b38d782
FC
453# [perl #77172]
454package rt77172;
455sub foo {} foo & & & foo;
456>>>>
457package rt77172;
458foo(&{&} & foo());
459####
507a68aa 460# variables as method names
09d856fb
CK
461my $bar;
462'Foo'->$bar('orz');
35a99a08 463'Foo'->$bar('orz') = 'a stranger stranger than before';
09d856fb 464####
507a68aa 465# constants as method names
09d856fb
CK
466'Foo'->bar('orz');
467####
507a68aa 468# constants as method names without ()
09d856fb 469'Foo'->bar;
0ced6c29 470####
28bfcb02 471# [perl #47359] "indirect" method call notation
1bf8bbb0
FC
472our @bar;
473foo{@bar}+1,->foo;
474(foo{@bar}+1),foo();
475foo{@bar}1 xor foo();
476>>>>
477our @bar;
478(foo { @bar } 1)->foo;
479(foo { @bar } 1), foo();
480foo { @bar } 1 xor foo();
481####
e9c69003 482# SKIP ?$] < 5.010 && "say not implemented on this Perl version"
205fef88 483# CONTEXT use feature ':5.10';
507a68aa 484# say
7ddd1a01
NC
485say 'foo';
486####
8f57bb34 487# SKIP ?$] < 5.010 && "say not implemented on this Perl version"
8f57bb34
NC
488# CONTEXT use 5.10.0;
489# say in the context of use 5.10.0
490say 'foo';
491####
492# SKIP ?$] < 5.010 && "say not implemented on this Perl version"
8f57bb34
NC
493# say with use 5.10.0
494use 5.10.0;
495say 'foo';
496>>>>
497no feature;
498use feature ':5.10';
499say 'foo';
500####
501# SKIP ?$] < 5.010 && "say not implemented on this Perl version"
502# say with use feature ':5.10';
503use feature ':5.10';
504say 'foo';
505>>>>
506use feature 'say', 'state', 'switch';
507say 'foo';
508####
509# SKIP ?$] < 5.010 && "say not implemented on this Perl version"
8f57bb34
NC
510# CONTEXT use feature ':5.10';
511# say with use 5.10.0 in the context of use feature
512use 5.10.0;
513say 'foo';
514>>>>
515no feature;
516use feature ':5.10';
517say 'foo';
518####
519# SKIP ?$] < 5.010 && "say not implemented on this Perl version"
520# CONTEXT use 5.10.0;
521# say with use feature ':5.10' in the context of use 5.10.0
522use feature ':5.10';
523say 'foo';
524>>>>
525say 'foo';
526####
527# SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
528# CONTEXT use feature ':5.15';
529# __SUB__
530__SUB__;
531####
532# SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
8f57bb34
NC
533# CONTEXT use 5.15.0;
534# __SUB__ in the context of use 5.15.0
535__SUB__;
536####
537# SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
8f57bb34
NC
538# __SUB__ with use 5.15.0
539use 5.15.0;
540__SUB__;
541>>>>
542no feature;
543use feature ':5.16';
544__SUB__;
545####
546# SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
547# __SUB__ with use feature ':5.15';
548use feature ':5.15';
549__SUB__;
550>>>>
551use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
552__SUB__;
553####
554# SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
8f57bb34
NC
555# CONTEXT use feature ':5.15';
556# __SUB__ with use 5.15.0 in the context of use feature
557use 5.15.0;
558__SUB__;
559>>>>
560no feature;
561use feature ':5.16';
562__SUB__;
563####
564# SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
565# CONTEXT use 5.15.0;
566# __SUB__ with use feature ':5.15' in the context of use 5.15.0
567use feature ':5.15';
568__SUB__;
569>>>>
570__SUB__;
571####
e9c69003 572# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
205fef88 573# CONTEXT use feature ':5.10';
507a68aa 574# state vars
0ced6c29
RGS
575state $x = 42;
576####
e9c69003 577# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
205fef88 578# CONTEXT use feature ':5.10';
507a68aa 579# state var assignment
7ddd1a01
NC
580{
581 my $y = (state $x = 42);
582}
583####
e9c69003 584# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
205fef88 585# CONTEXT use feature ':5.10';
c4a6f826 586# state vars in anonymous subroutines
7ddd1a01
NC
587$a = sub {
588 state $x;
589 return $x++;
590}
591;
644741fd
NC
592####
593# SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
507a68aa 594# each @array;
644741fd
NC
595each @ARGV;
596each @$a;
597####
598# SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
507a68aa 599# keys @array; values @array
644741fd
NC
600keys @$a if keys @ARGV;
601values @ARGV if values @$a;
35925e80 602####
507a68aa 603# Anonymous arrays and hashes, and references to them
35925e80
RGS
604my $a = {};
605my $b = \{};
606my $c = [];
607my $d = \[];
9210de83
FR
608####
609# SKIP ?$] < 5.010 && "smartmatch and given/when not implemented on this Perl version"
0f539b13 610# CONTEXT use feature ':5.10'; no warnings 'experimental::smartmatch';
507a68aa 611# implicit smartmatch in given/when
9210de83
FR
612given ('foo') {
613 when ('bar') { continue; }
614 when ($_ ~~ 'quux') { continue; }
615 default { 0; }
616}
7ecdd211 617####
507a68aa 618# conditions in elsifs (regression in change #33710 which fixed bug #37302)
7ecdd211
PJ
619if ($a) { x(); }
620elsif ($b) { x(); }
621elsif ($a and $b) { x(); }
622elsif ($a or $b) { x(); }
623else { x(); }
03b22f1b 624####
507a68aa 625# interpolation in regexps
03b22f1b
RGS
626my($y, $t);
627/x${y}z$t/;
227375e1 628####
4a4b8592 629# TODO new undocumented cpan-bug #33708
507a68aa 630# cpan-bug #33708
227375e1
RU
631%{$_ || {}}
632####
4a4b8592 633# TODO hash constants not yet fixed
507a68aa 634# cpan-bug #33708
227375e1
RU
635use constant H => { "#" => 1 }; H->{"#"}
636####
4a4b8592 637# TODO optimized away 0 not yet fixed
507a68aa 638# cpan-bug #33708
227375e1 639foreach my $i (@_) { 0 }
edbe35ea 640####
507a68aa 641# tests with not, not optimized
07f3cdf5 642my $c;
edbe35ea
VP
643x() unless $a;
644x() if not $a and $b;
645x() if $a and not $b;
646x() unless not $a and $b;
647x() unless $a and not $b;
648x() if not $a or $b;
649x() if $a or not $b;
650x() unless not $a or $b;
651x() unless $a or not $b;
07f3cdf5
VP
652x() if $a and not $b and $c;
653x() if not $a and $b and not $c;
654x() unless $a and not $b and $c;
655x() unless not $a and $b and not $c;
656x() if $a or not $b or $c;
657x() if not $a or $b or not $c;
658x() unless $a or not $b or $c;
659x() unless not $a or $b or not $c;
edbe35ea 660####
507a68aa 661# tests with not, optimized
07f3cdf5 662my $c;
edbe35ea
VP
663x() if not $a;
664x() unless not $a;
665x() if not $a and not $b;
666x() unless not $a and not $b;
667x() if not $a or not $b;
668x() unless not $a or not $b;
07f3cdf5
VP
669x() if not $a and not $b and $c;
670x() unless not $a and not $b and $c;
671x() if not $a or not $b or $c;
672x() unless not $a or not $b or $c;
673x() if not $a and not $b and not $c;
674x() unless not $a and not $b and not $c;
675x() if not $a or not $b or not $c;
676x() unless not $a or not $b or not $c;
677x() unless not $a or not $b or not $c;
edbe35ea 678>>>>
07f3cdf5 679my $c;
edbe35ea
VP
680x() unless $a;
681x() if $a;
682x() unless $a or $b;
683x() if $a or $b;
684x() unless $a and $b;
07f3cdf5
VP
685x() if $a and $b;
686x() if not $a || $b and $c;
687x() unless not $a || $b and $c;
688x() if not $a && $b or $c;
689x() unless not $a && $b or $c;
690x() unless $a or $b or $c;
691x() if $a or $b or $c;
692x() unless $a and $b and $c;
693x() if $a and $b and $c;
694x() unless not $a && $b && $c;
71c4dbc3 695####
507a68aa 696# tests that should be constant folded
71c4dbc3
VP
697x() if 1;
698x() if GLIPP;
699x() if !GLIPP;
700x() if GLIPP && GLIPP;
701x() if !GLIPP || GLIPP;
702x() if do { GLIPP };
703x() if do { no warnings 'void'; 5; GLIPP };
704x() if do { !GLIPP };
705if (GLIPP) { x() } else { z() }
706if (!GLIPP) { x() } else { z() }
707if (GLIPP) { x() } elsif (GLIPP) { z() }
708if (!GLIPP) { x() } elsif (GLIPP) { z() }
709if (GLIPP) { x() } elsif (!GLIPP) { z() }
710if (!GLIPP) { x() } elsif (!GLIPP) { z() }
711if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (GLIPP) { t() }
712if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
713if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
714>>>>
715x();
716x();
717'???';
718x();
719x();
720x();
721x();
722do {
723 '???'
724};
725do {
726 x()
727};
728do {
729 z()
730};
731do {
732 x()
733};
734do {
735 z()
736};
737do {
738 x()
739};
740'???';
741do {
742 t()
743};
744'???';
745!1;
746####
719c50dc
RGS
747# TODO constant deparsing has been backed out for 5.12
748# XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
507a68aa 749# tests that shouldn't be constant folded
ac0f1413
NC
750# It might be fundamentally impossible to make this work on ithreads, in which
751# case the TODO should become a SKIP
71c4dbc3
VP
752x() if $a;
753if ($a == 1) { x() } elsif ($b == 2) { z() }
754if (do { foo(); GLIPP }) { x() }
755if (do { $a++; GLIPP }) { x() }
756>>>>
757x() if $a;
758if ($a == 1) { x(); } elsif ($b == 2) { z(); }
2990415a
FR
759if (do { foo(); GLIPP }) { x(); }
760if (do { ++$a; GLIPP }) { x(); }
761####
0fa4a265 762# TODO constant deparsing has been backed out for 5.12
507a68aa 763# tests for deparsing constants
2990415a
FR
764warn PI;
765####
0fa4a265 766# TODO constant deparsing has been backed out for 5.12
507a68aa 767# tests for deparsing imported constants
3779476a 768warn O_TRUNC;
2990415a 769####
0fa4a265 770# TODO constant deparsing has been backed out for 5.12
507a68aa 771# tests for deparsing re-exported constants
2990415a
FR
772warn O_CREAT;
773####
0fa4a265 774# TODO constant deparsing has been backed out for 5.12
507a68aa 775# tests for deparsing imported constants that got deleted from the original namespace
aaf9c2b2 776warn O_APPEND;
2990415a 777####
0fa4a265
DM
778# TODO constant deparsing has been backed out for 5.12
779# XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
507a68aa 780# tests for deparsing constants which got turned into full typeglobs
ac0f1413
NC
781# It might be fundamentally impossible to make this work on ithreads, in which
782# case the TODO should become a SKIP
2990415a
FR
783warn O_EXCL;
784eval '@Fcntl::O_EXCL = qw/affe tiger/;';
785warn O_EXCL;
786####
0fa4a265 787# TODO constant deparsing has been backed out for 5.12
507a68aa 788# tests for deparsing of blessed constant with overloaded numification
2990415a 789warn OVERLOADED_NUMIFICATION;
79289e05 790####
507a68aa 791# strict
79289e05 792no strict;
415d4c68
FC
793print $x;
794use strict 'vars';
795print $main::x;
796use strict 'subs';
797print $main::x;
798use strict 'refs';
799print $main::x;
800no strict 'vars';
79289e05
NC
801$x;
802####
803# TODO Subsets of warnings could be encoded textually, rather than as bitflips.
507a68aa 804# subsets of warnings
79289e05
NC
805no warnings 'deprecated';
806my $x;
807####
808# TODO Better test for CPAN #33708 - the deparsed code has different behaviour
507a68aa 809# CPAN #33708
79289e05
NC
810use strict;
811no warnings;
812
813foreach (0..3) {
814 my $x = 2;
815 {
816 my $x if 0;
817 print ++$x, "\n";
818 }
819}
d83f38d8 820####
507a68aa 821# no attribute list
d83f38d8
NC
822my $pi = 4;
823####
2dc78664
NC
824# SKIP ?$] > 5.013006 && ":= is now a syntax error"
825# := treated as an empty attribute list
d83f38d8
NC
826no warnings;
827my $pi := 4;
828>>>>
829no warnings;
830my $pi = 4;
831####
507a68aa 832# : = empty attribute list
d83f38d8
NC
833my $pi : = 4;
834>>>>
835my $pi = 4;
689e417f 836####
507a68aa 837# in place sort
689e417f
VP
838our @a;
839my @b;
840@a = sort @a;
841@b = sort @b;
842();
843####
507a68aa 844# in place reverse
689e417f
VP
845our @a;
846my @b;
847@a = reverse @a;
848@b = reverse @b;
849();
06fc6867 850####
507a68aa 851# #71870 Use of uninitialized value in bitwise and B::Deparse
06fc6867
VP
852my($r, $s, @a);
853@a = split(/foo/, $s, 0);
854$r = qr/foo/;
855@a = split(/$r/, $s, 0);
856();
98a1a137 857####
507a68aa 858# package declaration before label
98a1a137
Z
859{
860 package Foo;
861 label: print 123;
862}
538f5756 863####
507a68aa 864# shift optimisation
538f5756
RZ
865shift;
866>>>>
867shift();
868####
507a68aa 869# shift optimisation
538f5756
RZ
870shift @_;
871####
507a68aa 872# shift optimisation
538f5756
RZ
873pop;
874>>>>
875pop();
876####
507a68aa 877# shift optimisation
538f5756 878pop @_;
a539498a 879####
507a68aa 880#[perl #20444]
a539498a
FC
881"foo" =~ (1 ? /foo/ : /bar/);
882"foo" =~ (1 ? y/foo// : /bar/);
5e5a1632 883"foo" =~ (1 ? y/foo//r : /bar/);
a539498a
FC
884"foo" =~ (1 ? s/foo// : /bar/);
885>>>>
886'foo' =~ ($_ =~ /foo/);
887'foo' =~ ($_ =~ tr/fo//);
5e5a1632 888'foo' =~ ($_ =~ tr/fo//r);
a539498a 889'foo' =~ ($_ =~ s/foo//);
e0ab66ad 890####
5e5a1632
FC
891# The fix for [perl #20444] broke this.
892'foo' =~ do { () };
893####
4b58603b
FC
894# [perl #81424] match against aelemfast_lex
895my @s;
896print /$s[1]/;
897####
36727b53
FC
898# /$#a/
899print /$#main::a/;
900####
b9bc576f 901# [perl #91318] /regexp/applaud
09622ee2
FC
902print /a/a, s/b/c/a;
903print /a/aa, s/b/c/aa;
904print /a/p, s/b/c/p;
905print /a/l, s/b/c/l;
906print /a/u, s/b/c/u;
b9bc576f
FC
907{
908 use feature "unicode_strings";
09622ee2 909 print /a/d, s/b/c/d;
b9bc576f
FC
910}
911{
912 use re "/u";
09622ee2 913 print /a/d, s/b/c/d;
b9bc576f 914}
dff5ffe4
FC
915{
916 use 5.012;
917 print /a/d, s/b/c/d;
918}
b9bc576f 919>>>>
09622ee2
FC
920print /a/a, s/b/c/a;
921print /a/aa, s/b/c/aa;
922print /a/p, s/b/c/p;
923print /a/l, s/b/c/l;
924print /a/u, s/b/c/u;
b9bc576f 925{
a8095af7 926 use feature 'unicode_strings';
09622ee2 927 print /a/d, s/b/c/d;
b9bc576f
FC
928}
929{
0bb01b05
FC
930 BEGIN { $^H{'reflags'} = '0';
931 $^H{'reflags_charset'} = '2'; }
09622ee2 932 print /a/d, s/b/c/d;
b9bc576f 933}
dff5ffe4
FC
934{
935 no feature;
936 use feature ':5.12';
937 print /a/d, s/b/c/d;
938}
b9bc576f 939####
e0ab66ad
NC
940# Test @threadsv_names under 5005threads
941foreach $' (1, 2) {
942 sleep $';
943}
e7afc405
FC
944####
945# y///r
946tr/a/b/r;
cb8157e3
FC
947####
948# y/uni/code/
949tr/\x{345}/\x{370}/;
cb8578ff
FC
950####
951# [perl #90898]
f4002a4b 952<a,>;
09dcfa7d
FC
953####
954# [perl #91008]
955each $@;
956keys $~;
957values $!;
5d8c42c2
FC
958####
959# readpipe with complex expression
960readpipe $a + $b;
93bad3fd
NC
961####
962# aelemfast
963$b::a[0] = 1;
964####
965# aelemfast for a lexical
966my @a;
967$a[0] = 1;
80e3f4ad
FC
968####
969# feature features without feature
0f539b13 970# CONTEXT no warnings 'experimental::smartmatch';
80e3f4ad 971CORE::state $x;
223b1722
FC
972CORE::say $x;
973CORE::given ($x) {
974 CORE::when (3) {
975 continue;
976 }
977 CORE::default {
978 CORE::break;
979 }
980}
981CORE::evalbytes '';
982() = CORE::__SUB__;
838f2281 983() = CORE::fc $x;
223b1722
FC
984####
985# feature features when feature has been disabled by use VERSION
0f539b13 986# CONTEXT no warnings 'experimental::smartmatch';
223b1722
FC
987use feature (sprintf(":%vd", $^V));
988use 1;
989CORE::state $x;
990CORE::say $x;
991CORE::given ($x) {
992 CORE::when (3) {
993 continue;
994 }
995 CORE::default {
996 CORE::break;
997 }
998}
999CORE::evalbytes '';
1000() = CORE::__SUB__;
1001>>>>
205fef88
NC
1002CORE::state $x;
1003CORE::say $x;
1004CORE::given ($x) {
1005 CORE::when (3) {
1006 continue;
1007 }
1008 CORE::default {
1009 CORE::break;
1010 }
1011}
1012CORE::evalbytes '';
1013() = CORE::__SUB__;
1014####
1015# (the above test with CONTEXT, and the output is equivalent but different)
0f539b13 1016# CONTEXT use feature ':5.10'; no warnings 'experimental::smartmatch';
205fef88
NC
1017# feature features when feature has been disabled by use VERSION
1018use feature (sprintf(":%vd", $^V));
1019use 1;
1020CORE::state $x;
1021CORE::say $x;
1022CORE::given ($x) {
1023 CORE::when (3) {
1024 continue;
1025 }
1026 CORE::default {
1027 CORE::break;
1028 }
1029}
1030CORE::evalbytes '';
1031() = CORE::__SUB__;
1032>>>>
0bb01b05
FC
1033no feature;
1034use feature ':default';
223b1722 1035CORE::state $x;
80e3f4ad
FC
1036CORE::say $x;
1037CORE::given ($x) {
1038 CORE::when (3) {
1039 continue;
1040 }
1041 CORE::default {
e36901c8 1042 CORE::break;
80e3f4ad
FC
1043 }
1044}
7d789282 1045CORE::evalbytes '';
84ed0108 1046() = CORE::__SUB__;
6ec73527 1047####
0bb01b05
FC
1048# Feature hints
1049use feature 'current_sub', 'evalbytes';
1050print;
1051use 1;
1052print;
1053use 5.014;
1054print;
1055no feature 'unicode_strings';
1056print;
1057>>>>
a8095af7 1058use feature 'current_sub', 'evalbytes';
0bb01b05
FC
1059print $_;
1060no feature;
1061use feature ':default';
1062print $_;
1063no feature;
1064use feature ':5.12';
1065print $_;
a8095af7 1066no feature 'unicode_strings';
0bb01b05
FC
1067print $_;
1068####
6ec73527
FC
1069# $#- $#+ $#{%} etc.
1070my @x;
5b6da579 1071@x = ($#{`}, $#{~}, $#{!}, $#{@}, $#{$}, $#{%}, $#{^}, $#{&}, $#{*});
6ec73527
FC
1072@x = ($#{(}, $#{)}, $#{[}, $#{{}, $#{]}, $#{}}, $#{'}, $#{"}, $#{,});
1073@x = ($#{<}, $#{.}, $#{>}, $#{/}, $#{?}, $#{=}, $#+, $#{\}, $#{|}, $#-);
1074@x = ($#{;}, $#{:});
61154ac0 1075####
ff683671
NC
1076# ${#} interpolated
1077# It's a known TODO that warnings are deparsed as bits, not textually.
1078no warnings;
61154ac0 1079() = "${#}a";
958ed56b 1080####
337d7381
FC
1081# [perl #86060] $( $| $) in regexps need braces
1082/${(}/;
1083/${|}/;
1084/${)}/;
1085/${(}${|}${)}/;
1086####
958ed56b
FC
1087# ()[...]
1088my(@a) = ()[()];
521795fe
FC
1089####
1090# sort(foo(bar))
1091# sort(foo(bar)) is interpreted as sort &foo(bar)
1092# sort foo(bar) is interpreted as sort foo bar
1093# parentheses are not optional in this case
1094print sort(foo('bar'));
1095>>>>
1096print sort(foo('bar'));
24fcb59f
FC
1097####
1098# substr assignment
1099substr(my $a, 0, 0) = (foo(), bar());
1100$a++;
04be0204 1101####
d1718a7c
FC
1102# This following line works around an unfixed bug that we are not trying to
1103# test for here:
1104# CONTEXT BEGIN { $^H{a} = "b"; delete $^H{a} } # make %^H localised
04be0204
FC
1105# hint hash
1106BEGIN { $^H{'foo'} = undef; }
1107{
1108 BEGIN { $^H{'bar'} = undef; }
1109 {
1110 BEGIN { $^H{'baz'} = undef; }
1111 {
1112 print $_;
1113 }
1114 print $_;
1115 }
1116 print $_;
1117}
035146a3
FC
1118BEGIN { $^H{q[']} = '('; }
1119print $_;
c306e834 1120####
d1718a7c
FC
1121# This following line works around an unfixed bug that we are not trying to
1122# test for here:
1123# CONTEXT BEGIN { $^H{a} = "b"; delete $^H{a} } # make %^H localised
c306e834
FC
1124# hint hash changes that serialise the same way with sort %hh
1125BEGIN { $^H{'a'} = 'b'; }
1126{
1127 BEGIN { $^H{'b'} = 'a'; delete $^H{'a'}; }
1128 print $_;
1129}
1130print $_;
94bb57f9
FC
1131####
1132# [perl #47361] do({}) and do +{} (variants of do-file)
1133do({});
1134do +{};
8b46c09b
FC
1135sub foo::do {}
1136package foo;
1137CORE::do({});
1138CORE::do +{};
94bb57f9
FC
1139>>>>
1140do({});
1141do({});
8b46c09b
FC
1142package foo;
1143CORE::do({});
1144CORE::do({});
9c56d9ea
FC
1145####
1146# [perl #77096] functions that do not follow the llafr
1147() = (return 1) + time;
1148() = (return ($1 + $2) * $3) + time;
1149() = (return ($a xor $b)) + time;
1150() = (do 'file') + time;
1151() = (do ($1 + $2) * $3) + time;
1152() = (do ($1 xor $2)) + time;
41df74e3
FC
1153() = (goto 1) + 3;
1154() = (require 'foo') + 3;
1155() = (require foo) + 3;
266da325 1156() = (CORE::dump 1) + 3;
41df74e3
FC
1157() = (last 1) + 3;
1158() = (next 1) + 3;
1159() = (redo 1) + 3;
5830412d
FC
1160() = (-R $_) + 3;
1161() = (-W $_) + 3;
1162() = (-X $_) + 3;
1163() = (-r $_) + 3;
1164() = (-w $_) + 3;
1165() = (-x $_) + 3;
2462c3cc 1166####
1cabb3b3
FC
1167# [perl #97476] not() *does* follow the llafr
1168$_ = ($a xor not +($1 || 2) ** 2);
1169####
4d8ac5c7
FC
1170# Precedence conundrums with argument-less function calls
1171() = (eof) + 1;
1172() = (return) + 1;
1173() = (return, 1);
7bc8c979
FC
1174() = warn;
1175() = warn() + 1;
4d8ac5c7
FC
1176() = setpgrp() + 1;
1177####
1eb0b7be
FC
1178# loopexes have assignment prec
1179() = (CORE::dump a) | 'b';
1180() = (goto a) | 'b';
1181() = (last a) | 'b';
1182() = (next a) | 'b';
1183() = (redo a) | 'b';
1184####
2462c3cc
FC
1185# [perl #63558] open local(*FH)
1186open local *FH;
564cd6cb 1187pipe local *FH, local *FH;
843b15cc 1188####
b89b7257
FC
1189# [perl #91416] open "string"
1190open 'open';
1191open '####';
1192open '^A';
1193open "\ca";
1194>>>>
1195open *open;
1196open '####';
1197open '^A';
1198open *^A;
1199####
be6cf5cf
FC
1200# "string"->[] ->{}
1201no strict 'vars';
1202() = 'open'->[0]; #aelemfast
1203() = '####'->[0];
1204() = '^A'->[0];
1205() = "\ca"->[0];
b861b87f 1206() = 'a::]b'->[0];
10e8e32b
FC
1207() = 'open'->[$_]; #aelem
1208() = '####'->[$_];
1209() = '^A'->[$_];
1210() = "\ca"->[$_];
b861b87f 1211() = 'a::]b'->[$_];
10e8e32b
FC
1212() = 'open'->{0}; #helem
1213() = '####'->{0};
1214() = '^A'->{0};
1215() = "\ca"->{0};
b861b87f 1216() = 'a::]b'->{0};
be6cf5cf 1217>>>>
415d4c68 1218no strict 'vars';
be6cf5cf
FC
1219() = $open[0];
1220() = '####'->[0];
1221() = '^A'->[0];
1222() = $^A[0];
b861b87f 1223() = 'a::]b'->[0];
10e8e32b
FC
1224() = $open[$_];
1225() = '####'->[$_];
1226() = '^A'->[$_];
1227() = $^A[$_];
b861b87f 1228() = 'a::]b'->[$_];
10e8e32b
FC
1229() = $open{'0'};
1230() = '####'->{'0'};
1231() = '^A'->{'0'};
1232() = $^A{'0'};
b861b87f 1233() = 'a::]b'->{'0'};
be6cf5cf 1234####
843b15cc
FC
1235# [perl #74740] -(f()) vs -f()
1236$_ = -(f());
c75b4828
FC
1237####
1238# require <binop>
1239require 'a' . $1;
afb60448
HY
1240####
1241#[perl #30504] foreach-my postfix/prefix difference
1242$_ = 'foo' foreach my ($foo1, $bar1, $baz1);
1243foreach (my ($foo2, $bar2, $baz2)) { $_ = 'foo' }
1244foreach my $i (my ($foo3, $bar3, $baz3)) { $i = 'foo' }
1245>>>>
1246$_ = 'foo' foreach (my($foo1, $bar1, $baz1));
1247foreach $_ (my($foo2, $bar2, $baz2)) {
1248 $_ = 'foo';
1249}
1250foreach my $i (my($foo3, $bar3, $baz3)) {
1251 $i = 'foo';
1252}
1253####
1254#[perl #108224] foreach with continue block
1255foreach (1 .. 3) { print } continue { print "\n" }
1256foreach (1 .. 3) { } continue { }
1257foreach my $i (1 .. 3) { print $i } continue { print "\n" }
1258foreach my $i (1 .. 3) { } continue { }
1259>>>>
1260foreach $_ (1 .. 3) {
1261 print $_;
1262}
1263continue {
1264 print "\n";
1265}
1266foreach $_ (1 .. 3) {
1267 ();
1268}
1269continue {
1270 ();
1271}
1272foreach my $i (1 .. 3) {
1273 print $i;
1274}
1275continue {
1276 print "\n";
1277}
1278foreach my $i (1 .. 3) {
1279 ();
1280}
1281continue {
1282 ();
1283}
bc1cc2c3
DM
1284####
1285# file handles
1286no strict;
1287my $mfh;
1288open F;
1289open *F;
1290open $fh;
1291open $mfh;
1292open 'a+b';
1293select *F;
1294select F;
1295select $f;
1296select $mfh;
1297select 'a+b';
a7fd8ef6
DM
1298####
1299# 'my' works with padrange op
1300my($z, @z);
1301my $m1;
1302$m1 = 1;
1303$z = $m1;
1304my $m2 = 2;
1305my($m3, $m4);
1306($m3, $m4) = (1, 2);
1307@z = ($m3, $m4);
1308my($m5, $m6) = (1, 2);
1309my($m7, undef, $m8) = (1, 2, 3);
1310@z = ($m7, undef, $m8);
1311($m7, undef, $m8) = (1, 2, 3);
1312####
1313# 'our/local' works with padrange op
1314no strict;
1315our($z, @z);
1316our $o1;
1317local $o11;
1318$o1 = 1;
1319local $o1 = 1;
1320$z = $o1;
1321$z = local $o1;
1322our $o2 = 2;
1323our($o3, $o4);
1324($o3, $o4) = (1, 2);
1325local($o3, $o4) = (1, 2);
1326@z = ($o3, $o4);
1327@z = local($o3, $o4);
1328our($o5, $o6) = (1, 2);
1329our($o7, undef, $o8) = (1, 2, 3);
1330@z = ($o7, undef, $o8);
1331@z = local($o7, undef, $o8);
1332($o7, undef, $o8) = (1, 2, 3);
1333local($o7, undef, $o8) = (1, 2, 3);
1334####
1335# 'state' works with padrange op
1336no strict;
1337use feature 'state';
1338state($z, @z);
1339state $s1;
1340$s1 = 1;
1341$z = $s1;
1342state $s2 = 2;
1343state($s3, $s4);
1344($s3, $s4) = (1, 2);
1345@z = ($s3, $s4);
1346# assignment of state lists isn't implemented yet
1347#state($s5, $s6) = (1, 2);
1348#state($s7, undef, $s8) = (1, 2, 3);
1349#@z = ($s7, undef, $s8);
1350($s7, undef, $s8) = (1, 2, 3);
1351####
1352# anon lists with padrange
1353my($a, $b);
1354my $c = [$a, $b];
1355my $d = {$a, $b};
1356####
1357# slices with padrange
1358my($a, $b);
1359my(@x, %y);
1360@x = @x[$a, $b];
1361@x = @y{$a, $b};
1362####
1363# binops with padrange
1364my($a, $b, $c);
1365$c = $a cmp $b;
1366$c = $a + $b;
1367$a += $b;
1368$c = $a - $b;
1369$a -= $b;
1370$c = my $a1 cmp $b;
1371$c = my $a2 + $b;
1372$a += my $b1;
1373$c = my $a3 - $b;
1374$a -= my $b2;
1375####
1376# 'x' with padrange
1377my($a, $b, $c, $d, @e);
1378$c = $a x $b;
1379$a x= $b;
1380@e = ($a) x $d;
1381@e = ($a, $b) x $d;
1382@e = ($a, $b, $c) x $d;
1383@e = ($a, 1) x $d;
d5524600
DM
1384####
1385# @_ with padrange
1386my($a, $b, $c) = @_;
ce4062e7
AC
1387####
1388# SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
1389# TODO unimplemented in B::Deparse; RT #116553
1390# lexical subroutine
1391use feature 'lexical_subs';
601448c3 1392no warnings "experimental::lexical_subs";
ce4062e7
AC
1393my sub f {}
1394print f();
f0cf3754
AC
1395####
1396# SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
1397# TODO unimplemented in B::Deparse; RT #116553
1398# lexical "state" subroutine
1399use feature 'state', 'lexical_subs';
1400no warnings 'experimental::lexical_subs';
1401state sub f {}
1402print f();