This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix some broken URLs found by Porting/checkURL.pl
[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;
e9c69003 14BEGIN {
c4a6f826 15 # BEGIN block is actually a subroutine :-)
e9c69003
NC
16 return unless $] > 5.009;
17 require feature;
18 feature->import(':5.10');
19}
507a68aa 20use Test::More;
1bb3cfc5 21use Config ();
87a42246
MS
22
23use B::Deparse;
09d856fb 24my $deparse = B::Deparse->new();
507a68aa 25isa_ok($deparse, 'B::Deparse', 'instantiate a B::Deparse object');
87a42246
MS
26
27# Tell B::Deparse about our ambient pragmas
0ced6c29
RGS
28{ my ($hint_bits, $warning_bits, $hinthash);
29 BEGIN { ($hint_bits, $warning_bits, $hinthash) = ($^H, ${^WARNING_BITS}, \%^H); }
87a42246
MS
30 $deparse->ambient_pragmas (
31 hint_bits => $hint_bits,
32 warning_bits => $warning_bits,
0ced6c29
RGS
33 '$[' => 0 + $[,
34 '%^H' => $hinthash,
87a42246
MS
35 );
36}
37
ad46c0be
RH
38$/ = "\n####\n";
39while (<DATA>) {
40 chomp;
e9c69003
NC
41 # This code is pinched from the t/lib/common.pl for TODO.
42 # It's not clear how to avoid duplication
b871937f
NC
43 # Now tweaked a bit to do skip or todo
44 my %reason;
45 foreach my $what (qw(skip todo)) {
46 s/^#\s*\U$what\E\s*(.*)\n//m and $reason{$what} = $1;
47 # If the SKIP reason starts ? then it's taken as a code snippet to
48 # evaluate. This provides the flexibility to have conditional SKIPs
49 if ($reason{$what} && $reason{$what} =~ s/^\?//) {
50 my $temp = eval $reason{$what};
51 if ($@) {
52 die "# In \U$what\E code reason:\n# $reason{$what}\n$@";
53 }
54 $reason{$what} = $temp;
e9c69003 55 }
e9c69003
NC
56 }
57
4a4b8592 58 s/^\s*#\s*(.*)$//mg;
507a68aa
NC
59 my $desc = $1;
60 die "Missing name in test $_" unless defined $desc;
e9c69003 61
b871937f 62 if ($reason{skip}) {
e9c69003 63 # Like this to avoid needing a label SKIP:
b871937f 64 Test::More->builder->skip($reason{skip});
e9c69003
NC
65 next;
66 }
67
ad46c0be
RH
68 my ($input, $expected);
69 if (/(.*)\n>>>>\n(.*)/s) {
70 ($input, $expected) = ($1, $2);
71 }
72 else {
73 ($input, $expected) = ($_, $_);
74 }
87a42246 75
ad46c0be 76 my $coderef = eval "sub {$input}";
87a42246 77
ad46c0be 78 if ($@) {
507a68aa 79 is($@, "", "compilation of $desc");
ad46c0be
RH
80 }
81 else {
82 my $deparsed = $deparse->coderef2text( $coderef );
31c6271a
RD
83 my $regex = $expected;
84 $regex =~ s/(\S+)/\Q$1/g;
85 $regex =~ s/\s+/\\s+/g;
86 $regex = '^\{\s*' . $regex . '\s*\}$';
b871937f 87
4a4b8592 88 local $::TODO = $reason{todo};
507a68aa 89 like($deparsed, qr/$regex/, $desc);
87a42246 90 }
87a42246
MS
91}
92
87a42246 93use constant 'c', 'stuff';
507a68aa
NC
94is((eval "sub ".$deparse->coderef2text(\&c))->(), 'stuff',
95 'the subroutine generated by use constant deparses');
87a42246 96
09d856fb 97my $a = 0;
507a68aa
NC
98is($deparse->coderef2text(sub{(-1) ** $a }), "{\n (-1) ** \$a;\n}",
99 'anon sub capturing an external lexical');
87a42246 100
d989cdac
SM
101use constant cr => ['hello'];
102my $string = "sub " . $deparse->coderef2text(\&cr);
0707d6cc 103my $val = (eval $string)->() or diag $string;
507a68aa
NC
104is(ref($val), 'ARRAY', 'constant array references deparse');
105is($val->[0], 'hello', 'and return the correct value');
87a42246 106
87a42246 107my $path = join " ", map { qq["-I$_"] } @INC;
87a42246 108
7cde0a5f 109$a = `$^X $path "-MO=Deparse" -anlwi.bak -e 1 2>&1`;
e69a2255 110$a =~ s/-e syntax OK\n//g;
d2bc402e 111$a =~ s/.*possible typo.*\n//; # Remove warning line
87a42246
MS
112$a =~ s{\\340\\242}{\\s} if (ord("\\") == 224); # EBCDIC, cp 1047 or 037
113$a =~ s{\\274\\242}{\\s} if (ord("\\") == 188); # $^O eq 'posix-bc'
114$b = <<'EOF';
d2bc402e
RGS
115BEGIN { $^I = ".bak"; }
116BEGIN { $^W = 1; }
117BEGIN { $/ = "\n"; $\ = "\n"; }
87a42246
MS
118LINE: while (defined($_ = <ARGV>)) {
119 chomp $_;
f86ea535 120 our(@F) = split(' ', $_, 0);
87a42246
MS
121 '???';
122}
87a42246 123EOF
507a68aa
NC
124is($a, $b,
125 'command line flags deparse as BEGIN blocks setting control variables');
87a42246 126
5b4ee549
NC
127$a = `$^X $path "-MO=Deparse" -e "use constant PI => 4" 2>&1`;
128$a =~ s/-e syntax OK\n//g;
129is($a, "use constant ('PI', 4);\n",
130 "Proxy Constant Subroutines must not show up as (incorrect) prototypes");
131
579a54dc 132#Re: perlbug #35857, patch #24505
b3980c39
YO
133#handle warnings::register-ed packages properly.
134package B::Deparse::Wrapper;
135use strict;
136use warnings;
137use warnings::register;
138sub getcode {
579a54dc 139 my $deparser = B::Deparse->new();
b3980c39
YO
140 return $deparser->coderef2text(shift);
141}
142
2990415a
FR
143package Moo;
144use overload '0+' => sub { 42 };
145
b3980c39
YO
146package main;
147use strict;
148use warnings;
71c4dbc3 149use constant GLIPP => 'glipp';
2990415a
FR
150use constant PI => 4;
151use constant OVERLOADED_NUMIFICATION => bless({}, 'Moo');
3779476a 152use Fcntl qw/O_TRUNC O_APPEND O_EXCL/;
aaf9c2b2 153BEGIN { delete $::Fcntl::{O_APPEND}; }
2990415a 154use POSIX qw/O_CREAT/;
b3980c39 155sub test {
579a54dc
RGS
156 my $val = shift;
157 my $res = B::Deparse::Wrapper::getcode($val);
507a68aa
NC
158 like($res, qr/use warnings/,
159 '[perl #35857] [PATCH] B::Deparse doesnt handle warnings register properly');
b3980c39
YO
160}
161my ($q,$p);
162my $x=sub { ++$q,++$p };
163test($x);
164eval <<EOFCODE and test($x);
165 package bar;
166 use strict;
167 use warnings;
168 use warnings::register;
169 package main;
170 1
171EOFCODE
172
d1dc589d
FC
173# Exotic sub declarations
174$a = `$^X $path "-MO=Deparse" -e "sub ::::{}sub ::::::{}" 2>&1`;
175$a =~ s/-e syntax OK\n//g;
176is($a, <<'EOCODG', "sub :::: and sub ::::::");
177sub :::: {
178
179}
180sub :::::: {
181
182}
183EOCODG
184
640d5d41
FC
185# [perl #33752]
186{
187 my $code = <<"EOCODE";
188{
189 our \$\x{1e1f}\x{14d}\x{14d};
190}
191EOCODE
192 my $deparsed
193 = $deparse->coderef2text(eval "sub { our \$\x{1e1f}\x{14d}\x{14d} }" );
194 s/$ \n//x for $deparsed, $code;
195 is $deparsed, $code, 'our $funny_Unicode_chars';
196}
197
bdabb2d5
FC
198# [perl #62500]
199$a =
200 `$^X $path "-MO=Deparse" -e "BEGIN{*CORE::GLOBAL::require=sub{1}}" 2>&1`;
201$a =~ s/-e syntax OK\n//g;
202is($a, <<'EOCODF', "CORE::GLOBAL::require override causing panick");
203sub BEGIN {
204 *CORE::GLOBAL::require = sub {
205 1;
206 }
207 ;
208}
209EOCODF
210
507a68aa
NC
211done_testing();
212
ad46c0be 213__DATA__
507a68aa 214# A constant
ad46c0be
RH
2151;
216####
507a68aa 217# Constants in a block
ad46c0be
RH
218{
219 no warnings;
220 '???';
221 2;
222}
223####
507a68aa 224# Lexical and simple arithmetic
ad46c0be
RH
225my $test;
226++$test and $test /= 2;
227>>>>
228my $test;
229$test /= 2 if ++$test;
230####
507a68aa 231# list x
ad46c0be
RH
232-((1, 2) x 2);
233####
507a68aa 234# lvalue sub
ad46c0be
RH
235{
236 my $test = sub : lvalue {
237 my $x;
238 }
239 ;
240}
241####
507a68aa 242# method
ad46c0be
RH
243{
244 my $test = sub : method {
245 my $x;
246 }
247 ;
248}
249####
507a68aa 250# block with continue
87a42246 251{
ad46c0be 252 234;
f99a63a2 253}
ad46c0be
RH
254continue {
255 123;
87a42246 256}
ce4e655d 257####
507a68aa 258# lexical and package scalars
ce4e655d
RH
259my $x;
260print $main::x;
261####
507a68aa 262# lexical and package arrays
ce4e655d
RH
263my @x;
264print $main::x[1];
14a55f98 265####
507a68aa 266# lexical and package hashes
14a55f98
RH
267my %x;
268$x{warn()};
ad8caead 269####
507a68aa 270# <>
ad8caead
RGS
271my $foo;
272$_ .= <ARGV> . <$foo>;
cef22867 273####
507a68aa 274# \x{}
11454c59 275my $foo = "Ab\x{100}\200\x{200}\237Cd\000Ef\x{1000}\cA\x{2000}\cZ";
4ae52e81 276####
507a68aa 277# s///e
4ae52e81 278s/x/'y';/e;
241416b8 279####
507a68aa 280# block
241416b8
DM
281{ my $x; }
282####
507a68aa 283# while 1
241416b8
DM
284while (1) { my $k; }
285####
507a68aa 286# trailing for
241416b8
DM
287my ($x,@a);
288$x=1 for @a;
289>>>>
290my($x, @a);
0bb5f065 291$x = 1 foreach (@a);
241416b8 292####
507a68aa 293# 2 arguments in a 3 argument for
241416b8
DM
294for (my $i = 0; $i < 2;) {
295 my $z = 1;
296}
297####
507a68aa 298# 3 argument for
241416b8
DM
299for (my $i = 0; $i < 2; ++$i) {
300 my $z = 1;
301}
302####
507a68aa 303# 3 argument for again
241416b8
DM
304for (my $i = 0; $i < 2; ++$i) {
305 my $z = 1;
306}
307####
507a68aa 308# while/continue
241416b8
DM
309my $i;
310while ($i) { my $z = 1; } continue { $i = 99; }
311####
507a68aa 312# foreach with my
09d856fb 313foreach my $i (1, 2) {
241416b8
DM
314 my $z = 1;
315}
316####
507a68aa 317# foreach
241416b8
DM
318my $i;
319foreach $i (1, 2) {
320 my $z = 1;
321}
322####
507a68aa 323# foreach, 2 mys
241416b8
DM
324my $i;
325foreach my $i (1, 2) {
326 my $z = 1;
327}
328####
507a68aa 329# foreach
241416b8
DM
330foreach my $i (1, 2) {
331 my $z = 1;
332}
333####
507a68aa 334# foreach with our
241416b8
DM
335foreach our $i (1, 2) {
336 my $z = 1;
337}
338####
507a68aa 339# foreach with my and our
241416b8
DM
340my $i;
341foreach our $i (1, 2) {
342 my $z = 1;
343}
3ac6e0f9 344####
507a68aa 345# reverse sort
3ac6e0f9
RGS
346my @x;
347print reverse sort(@x);
348####
507a68aa 349# sort with cmp
3ac6e0f9
RGS
350my @x;
351print((sort {$b cmp $a} @x));
352####
507a68aa 353# reverse sort with block
3ac6e0f9
RGS
354my @x;
355print((reverse sort {$b <=> $a} @x));
36d57d93 356####
507a68aa 357# foreach reverse
36d57d93
RGS
358our @a;
359print $_ foreach (reverse @a);
aae53c41 360####
507a68aa 361# foreach reverse (not inplace)
aae53c41
RGS
362our @a;
363print $_ foreach (reverse 1, 2..5);
f86ea535 364####
507a68aa 365# bug #38684
f86ea535
SM
366our @ary;
367@ary = split(' ', 'foo', 0);
31c6271a 368####
507a68aa 369# bug #40055
31c6271a
RD
370do { () };
371####
507a68aa 372# bug #40055
31c6271a 373do { my $x = 1; $x };
d9002312 374####
507a68aa 375# <20061012113037.GJ25805@c4.convolution.nl>
d9002312
SM
376my $f = sub {
377 +{[]};
378} ;
8b2d6640 379####
507a68aa 380# bug #43010
8b2d6640
FC
381'!@$%'->();
382####
507a68aa 383# bug #43010
8b2d6640
FC
384::();
385####
507a68aa 386# bug #43010
8b2d6640
FC
387'::::'->();
388####
507a68aa 389# bug #43010
8b2d6640 390&::::;
09d856fb 391####
507a68aa 392# variables as method names
09d856fb
CK
393my $bar;
394'Foo'->$bar('orz');
35a99a08 395'Foo'->$bar('orz') = 'a stranger stranger than before';
09d856fb 396####
507a68aa 397# constants as method names
09d856fb
CK
398'Foo'->bar('orz');
399####
507a68aa 400# constants as method names without ()
09d856fb 401'Foo'->bar;
0ced6c29 402####
e9c69003 403# SKIP ?$] < 5.010 && "say not implemented on this Perl version"
507a68aa 404# say
7ddd1a01
NC
405say 'foo';
406####
e9c69003 407# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
507a68aa 408# state vars
0ced6c29
RGS
409state $x = 42;
410####
e9c69003 411# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
507a68aa 412# state var assignment
7ddd1a01
NC
413{
414 my $y = (state $x = 42);
415}
416####
e9c69003 417# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
c4a6f826 418# state vars in anonymous subroutines
7ddd1a01
NC
419$a = sub {
420 state $x;
421 return $x++;
422}
423;
644741fd
NC
424####
425# SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
507a68aa 426# each @array;
644741fd
NC
427each @ARGV;
428each @$a;
429####
430# SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
507a68aa 431# keys @array; values @array
644741fd
NC
432keys @$a if keys @ARGV;
433values @ARGV if values @$a;
35925e80 434####
507a68aa 435# Anonymous arrays and hashes, and references to them
35925e80
RGS
436my $a = {};
437my $b = \{};
438my $c = [];
439my $d = \[];
9210de83
FR
440####
441# SKIP ?$] < 5.010 && "smartmatch and given/when not implemented on this Perl version"
507a68aa 442# implicit smartmatch in given/when
9210de83
FR
443given ('foo') {
444 when ('bar') { continue; }
445 when ($_ ~~ 'quux') { continue; }
446 default { 0; }
447}
7ecdd211 448####
507a68aa 449# conditions in elsifs (regression in change #33710 which fixed bug #37302)
7ecdd211
PJ
450if ($a) { x(); }
451elsif ($b) { x(); }
452elsif ($a and $b) { x(); }
453elsif ($a or $b) { x(); }
454else { x(); }
03b22f1b 455####
507a68aa 456# interpolation in regexps
03b22f1b
RGS
457my($y, $t);
458/x${y}z$t/;
227375e1 459####
4a4b8592 460# TODO new undocumented cpan-bug #33708
507a68aa 461# cpan-bug #33708
227375e1
RU
462%{$_ || {}}
463####
4a4b8592 464# TODO hash constants not yet fixed
507a68aa 465# cpan-bug #33708
227375e1
RU
466use constant H => { "#" => 1 }; H->{"#"}
467####
4a4b8592 468# TODO optimized away 0 not yet fixed
507a68aa 469# cpan-bug #33708
227375e1 470foreach my $i (@_) { 0 }
edbe35ea 471####
507a68aa 472# tests with not, not optimized
07f3cdf5 473my $c;
edbe35ea
VP
474x() unless $a;
475x() if not $a and $b;
476x() if $a and not $b;
477x() unless not $a and $b;
478x() unless $a and not $b;
479x() if not $a or $b;
480x() if $a or not $b;
481x() unless not $a or $b;
482x() unless $a or not $b;
07f3cdf5
VP
483x() if $a and not $b and $c;
484x() if not $a and $b and not $c;
485x() unless $a and not $b and $c;
486x() unless not $a and $b and not $c;
487x() if $a or not $b or $c;
488x() if not $a or $b or not $c;
489x() unless $a or not $b or $c;
490x() unless not $a or $b or not $c;
edbe35ea 491####
507a68aa 492# tests with not, optimized
07f3cdf5 493my $c;
edbe35ea
VP
494x() if not $a;
495x() unless not $a;
496x() if not $a and not $b;
497x() unless not $a and not $b;
498x() if not $a or not $b;
499x() unless not $a or not $b;
07f3cdf5
VP
500x() if not $a and not $b and $c;
501x() unless not $a and not $b and $c;
502x() if not $a or not $b or $c;
503x() unless not $a or not $b or $c;
504x() if not $a and not $b and not $c;
505x() unless not $a and not $b and not $c;
506x() if not $a or not $b or not $c;
507x() unless not $a or not $b or not $c;
508x() unless not $a or not $b or not $c;
edbe35ea 509>>>>
07f3cdf5 510my $c;
edbe35ea
VP
511x() unless $a;
512x() if $a;
513x() unless $a or $b;
514x() if $a or $b;
515x() unless $a and $b;
07f3cdf5
VP
516x() if $a and $b;
517x() if not $a || $b and $c;
518x() unless not $a || $b and $c;
519x() if not $a && $b or $c;
520x() unless not $a && $b or $c;
521x() unless $a or $b or $c;
522x() if $a or $b or $c;
523x() unless $a and $b and $c;
524x() if $a and $b and $c;
525x() unless not $a && $b && $c;
71c4dbc3 526####
507a68aa 527# tests that should be constant folded
71c4dbc3
VP
528x() if 1;
529x() if GLIPP;
530x() if !GLIPP;
531x() if GLIPP && GLIPP;
532x() if !GLIPP || GLIPP;
533x() if do { GLIPP };
534x() if do { no warnings 'void'; 5; GLIPP };
535x() if do { !GLIPP };
536if (GLIPP) { x() } else { z() }
537if (!GLIPP) { x() } else { z() }
538if (GLIPP) { x() } elsif (GLIPP) { z() }
539if (!GLIPP) { x() } elsif (GLIPP) { z() }
540if (GLIPP) { x() } elsif (!GLIPP) { z() }
541if (!GLIPP) { x() } elsif (!GLIPP) { z() }
542if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (GLIPP) { t() }
543if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
544if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
545>>>>
546x();
547x();
548'???';
549x();
550x();
551x();
552x();
553do {
554 '???'
555};
556do {
557 x()
558};
559do {
560 z()
561};
562do {
563 x()
564};
565do {
566 z()
567};
568do {
569 x()
570};
571'???';
572do {
573 t()
574};
575'???';
576!1;
577####
719c50dc
RGS
578# TODO constant deparsing has been backed out for 5.12
579# XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
507a68aa 580# tests that shouldn't be constant folded
ac0f1413
NC
581# It might be fundamentally impossible to make this work on ithreads, in which
582# case the TODO should become a SKIP
71c4dbc3
VP
583x() if $a;
584if ($a == 1) { x() } elsif ($b == 2) { z() }
585if (do { foo(); GLIPP }) { x() }
586if (do { $a++; GLIPP }) { x() }
587>>>>
588x() if $a;
589if ($a == 1) { x(); } elsif ($b == 2) { z(); }
2990415a
FR
590if (do { foo(); GLIPP }) { x(); }
591if (do { ++$a; GLIPP }) { x(); }
592####
0fa4a265 593# TODO constant deparsing has been backed out for 5.12
507a68aa 594# tests for deparsing constants
2990415a
FR
595warn PI;
596####
0fa4a265 597# TODO constant deparsing has been backed out for 5.12
507a68aa 598# tests for deparsing imported constants
3779476a 599warn O_TRUNC;
2990415a 600####
0fa4a265 601# TODO constant deparsing has been backed out for 5.12
507a68aa 602# tests for deparsing re-exported constants
2990415a
FR
603warn O_CREAT;
604####
0fa4a265 605# TODO constant deparsing has been backed out for 5.12
507a68aa 606# tests for deparsing imported constants that got deleted from the original namespace
aaf9c2b2 607warn O_APPEND;
2990415a 608####
0fa4a265
DM
609# TODO constant deparsing has been backed out for 5.12
610# XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
507a68aa 611# tests for deparsing constants which got turned into full typeglobs
ac0f1413
NC
612# It might be fundamentally impossible to make this work on ithreads, in which
613# case the TODO should become a SKIP
2990415a
FR
614warn O_EXCL;
615eval '@Fcntl::O_EXCL = qw/affe tiger/;';
616warn O_EXCL;
617####
0fa4a265 618# TODO constant deparsing has been backed out for 5.12
507a68aa 619# tests for deparsing of blessed constant with overloaded numification
2990415a 620warn OVERLOADED_NUMIFICATION;
79289e05
NC
621####
622# TODO Only strict 'refs' currently supported
507a68aa 623# strict
79289e05
NC
624no strict;
625$x;
626####
627# TODO Subsets of warnings could be encoded textually, rather than as bitflips.
507a68aa 628# subsets of warnings
79289e05
NC
629no warnings 'deprecated';
630my $x;
631####
632# TODO Better test for CPAN #33708 - the deparsed code has different behaviour
507a68aa 633# CPAN #33708
79289e05
NC
634use strict;
635no warnings;
636
637foreach (0..3) {
638 my $x = 2;
639 {
640 my $x if 0;
641 print ++$x, "\n";
642 }
643}
d83f38d8 644####
507a68aa 645# no attribute list
d83f38d8
NC
646my $pi = 4;
647####
2dc78664
NC
648# SKIP ?$] > 5.013006 && ":= is now a syntax error"
649# := treated as an empty attribute list
d83f38d8
NC
650no warnings;
651my $pi := 4;
652>>>>
653no warnings;
654my $pi = 4;
655####
507a68aa 656# : = empty attribute list
d83f38d8
NC
657my $pi : = 4;
658>>>>
659my $pi = 4;
689e417f 660####
507a68aa 661# in place sort
689e417f
VP
662our @a;
663my @b;
664@a = sort @a;
665@b = sort @b;
666();
667####
507a68aa 668# in place reverse
689e417f
VP
669our @a;
670my @b;
671@a = reverse @a;
672@b = reverse @b;
673();
06fc6867 674####
507a68aa 675# #71870 Use of uninitialized value in bitwise and B::Deparse
06fc6867
VP
676my($r, $s, @a);
677@a = split(/foo/, $s, 0);
678$r = qr/foo/;
679@a = split(/$r/, $s, 0);
680();
98a1a137 681####
507a68aa 682# package declaration before label
98a1a137
Z
683{
684 package Foo;
685 label: print 123;
686}
538f5756 687####
507a68aa 688# shift optimisation
538f5756
RZ
689shift;
690>>>>
691shift();
692####
507a68aa 693# shift optimisation
538f5756
RZ
694shift @_;
695####
507a68aa 696# shift optimisation
538f5756
RZ
697pop;
698>>>>
699pop();
700####
507a68aa 701# shift optimisation
538f5756 702pop @_;
a539498a 703####
507a68aa 704#[perl #20444]
a539498a
FC
705"foo" =~ (1 ? /foo/ : /bar/);
706"foo" =~ (1 ? y/foo// : /bar/);
707"foo" =~ (1 ? s/foo// : /bar/);
708>>>>
709'foo' =~ ($_ =~ /foo/);
710'foo' =~ ($_ =~ tr/fo//);
711'foo' =~ ($_ =~ s/foo//);
e0ab66ad
NC
712####
713# Test @threadsv_names under 5005threads
714foreach $' (1, 2) {
715 sleep $';
716}
e7afc405
FC
717####
718# y///r
719tr/a/b/r;
cb8157e3
FC
720####
721# y/uni/code/
722tr/\x{345}/\x{370}/;
cb8578ff
FC
723####
724# [perl #90898]
f4002a4b 725<a,>;
09dcfa7d
FC
726####
727# [perl #91008]
728each $@;
729keys $~;
730values $!;
5d8c42c2
FC
731####
732# readpipe with complex expression
733readpipe $a + $b;