This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix deparsing of subs named :::: and ::::::
[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');
395####
507a68aa 396# constants as method names
09d856fb
CK
397'Foo'->bar('orz');
398####
507a68aa 399# constants as method names without ()
09d856fb 400'Foo'->bar;
0ced6c29 401####
e9c69003 402# SKIP ?$] < 5.010 && "say not implemented on this Perl version"
507a68aa 403# say
7ddd1a01
NC
404say 'foo';
405####
e9c69003 406# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
507a68aa 407# state vars
0ced6c29
RGS
408state $x = 42;
409####
e9c69003 410# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
507a68aa 411# state var assignment
7ddd1a01
NC
412{
413 my $y = (state $x = 42);
414}
415####
e9c69003 416# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
c4a6f826 417# state vars in anonymous subroutines
7ddd1a01
NC
418$a = sub {
419 state $x;
420 return $x++;
421}
422;
644741fd
NC
423####
424# SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
507a68aa 425# each @array;
644741fd
NC
426each @ARGV;
427each @$a;
428####
429# SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
507a68aa 430# keys @array; values @array
644741fd
NC
431keys @$a if keys @ARGV;
432values @ARGV if values @$a;
35925e80 433####
507a68aa 434# Anonymous arrays and hashes, and references to them
35925e80
RGS
435my $a = {};
436my $b = \{};
437my $c = [];
438my $d = \[];
9210de83
FR
439####
440# SKIP ?$] < 5.010 && "smartmatch and given/when not implemented on this Perl version"
507a68aa 441# implicit smartmatch in given/when
9210de83
FR
442given ('foo') {
443 when ('bar') { continue; }
444 when ($_ ~~ 'quux') { continue; }
445 default { 0; }
446}
7ecdd211 447####
507a68aa 448# conditions in elsifs (regression in change #33710 which fixed bug #37302)
7ecdd211
PJ
449if ($a) { x(); }
450elsif ($b) { x(); }
451elsif ($a and $b) { x(); }
452elsif ($a or $b) { x(); }
453else { x(); }
03b22f1b 454####
507a68aa 455# interpolation in regexps
03b22f1b
RGS
456my($y, $t);
457/x${y}z$t/;
227375e1 458####
4a4b8592 459# TODO new undocumented cpan-bug #33708
507a68aa 460# cpan-bug #33708
227375e1
RU
461%{$_ || {}}
462####
4a4b8592 463# TODO hash constants not yet fixed
507a68aa 464# cpan-bug #33708
227375e1
RU
465use constant H => { "#" => 1 }; H->{"#"}
466####
4a4b8592 467# TODO optimized away 0 not yet fixed
507a68aa 468# cpan-bug #33708
227375e1 469foreach my $i (@_) { 0 }
edbe35ea 470####
507a68aa 471# tests with not, not optimized
07f3cdf5 472my $c;
edbe35ea
VP
473x() unless $a;
474x() if not $a and $b;
475x() if $a and not $b;
476x() unless not $a and $b;
477x() unless $a and not $b;
478x() if not $a or $b;
479x() if $a or not $b;
480x() unless not $a or $b;
481x() unless $a or not $b;
07f3cdf5
VP
482x() if $a and not $b and $c;
483x() if not $a and $b and not $c;
484x() unless $a and not $b and $c;
485x() unless not $a and $b and not $c;
486x() if $a or not $b or $c;
487x() if not $a or $b or not $c;
488x() unless $a or not $b or $c;
489x() unless not $a or $b or not $c;
edbe35ea 490####
507a68aa 491# tests with not, optimized
07f3cdf5 492my $c;
edbe35ea
VP
493x() if not $a;
494x() unless not $a;
495x() if not $a and not $b;
496x() unless not $a and not $b;
497x() if not $a or not $b;
498x() unless not $a or not $b;
07f3cdf5
VP
499x() if not $a and not $b and $c;
500x() unless not $a and not $b and $c;
501x() if not $a or not $b or $c;
502x() unless not $a or not $b or $c;
503x() if not $a and not $b and not $c;
504x() unless not $a and not $b and not $c;
505x() if not $a or not $b or not $c;
506x() unless not $a or not $b or not $c;
507x() unless not $a or not $b or not $c;
edbe35ea 508>>>>
07f3cdf5 509my $c;
edbe35ea
VP
510x() unless $a;
511x() if $a;
512x() unless $a or $b;
513x() if $a or $b;
514x() unless $a and $b;
07f3cdf5
VP
515x() if $a and $b;
516x() if not $a || $b and $c;
517x() unless not $a || $b and $c;
518x() if not $a && $b or $c;
519x() unless not $a && $b or $c;
520x() unless $a or $b or $c;
521x() if $a or $b or $c;
522x() unless $a and $b and $c;
523x() if $a and $b and $c;
524x() unless not $a && $b && $c;
71c4dbc3 525####
507a68aa 526# tests that should be constant folded
71c4dbc3
VP
527x() if 1;
528x() if GLIPP;
529x() if !GLIPP;
530x() if GLIPP && GLIPP;
531x() if !GLIPP || GLIPP;
532x() if do { GLIPP };
533x() if do { no warnings 'void'; 5; GLIPP };
534x() if do { !GLIPP };
535if (GLIPP) { x() } else { z() }
536if (!GLIPP) { x() } else { z() }
537if (GLIPP) { x() } elsif (GLIPP) { 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() } elsif (GLIPP) { t() }
542if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
543if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
544>>>>
545x();
546x();
547'???';
548x();
549x();
550x();
551x();
552do {
553 '???'
554};
555do {
556 x()
557};
558do {
559 z()
560};
561do {
562 x()
563};
564do {
565 z()
566};
567do {
568 x()
569};
570'???';
571do {
572 t()
573};
574'???';
575!1;
576####
719c50dc
RGS
577# TODO constant deparsing has been backed out for 5.12
578# XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
507a68aa 579# tests that shouldn't be constant folded
ac0f1413
NC
580# It might be fundamentally impossible to make this work on ithreads, in which
581# case the TODO should become a SKIP
71c4dbc3
VP
582x() if $a;
583if ($a == 1) { x() } elsif ($b == 2) { z() }
584if (do { foo(); GLIPP }) { x() }
585if (do { $a++; GLIPP }) { x() }
586>>>>
587x() if $a;
588if ($a == 1) { x(); } elsif ($b == 2) { z(); }
2990415a
FR
589if (do { foo(); GLIPP }) { x(); }
590if (do { ++$a; GLIPP }) { x(); }
591####
0fa4a265 592# TODO constant deparsing has been backed out for 5.12
507a68aa 593# tests for deparsing constants
2990415a
FR
594warn PI;
595####
0fa4a265 596# TODO constant deparsing has been backed out for 5.12
507a68aa 597# tests for deparsing imported constants
3779476a 598warn O_TRUNC;
2990415a 599####
0fa4a265 600# TODO constant deparsing has been backed out for 5.12
507a68aa 601# tests for deparsing re-exported constants
2990415a
FR
602warn O_CREAT;
603####
0fa4a265 604# TODO constant deparsing has been backed out for 5.12
507a68aa 605# tests for deparsing imported constants that got deleted from the original namespace
aaf9c2b2 606warn O_APPEND;
2990415a 607####
0fa4a265
DM
608# TODO constant deparsing has been backed out for 5.12
609# XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
507a68aa 610# tests for deparsing constants which got turned into full typeglobs
ac0f1413
NC
611# It might be fundamentally impossible to make this work on ithreads, in which
612# case the TODO should become a SKIP
2990415a
FR
613warn O_EXCL;
614eval '@Fcntl::O_EXCL = qw/affe tiger/;';
615warn O_EXCL;
616####
0fa4a265 617# TODO constant deparsing has been backed out for 5.12
507a68aa 618# tests for deparsing of blessed constant with overloaded numification
2990415a 619warn OVERLOADED_NUMIFICATION;
79289e05
NC
620####
621# TODO Only strict 'refs' currently supported
507a68aa 622# strict
79289e05
NC
623no strict;
624$x;
625####
626# TODO Subsets of warnings could be encoded textually, rather than as bitflips.
507a68aa 627# subsets of warnings
79289e05
NC
628no warnings 'deprecated';
629my $x;
630####
631# TODO Better test for CPAN #33708 - the deparsed code has different behaviour
507a68aa 632# CPAN #33708
79289e05
NC
633use strict;
634no warnings;
635
636foreach (0..3) {
637 my $x = 2;
638 {
639 my $x if 0;
640 print ++$x, "\n";
641 }
642}
d83f38d8 643####
507a68aa 644# no attribute list
d83f38d8
NC
645my $pi = 4;
646####
2dc78664
NC
647# SKIP ?$] > 5.013006 && ":= is now a syntax error"
648# := treated as an empty attribute list
d83f38d8
NC
649no warnings;
650my $pi := 4;
651>>>>
652no warnings;
653my $pi = 4;
654####
507a68aa 655# : = empty attribute list
d83f38d8
NC
656my $pi : = 4;
657>>>>
658my $pi = 4;
689e417f 659####
507a68aa 660# in place sort
689e417f
VP
661our @a;
662my @b;
663@a = sort @a;
664@b = sort @b;
665();
666####
507a68aa 667# in place reverse
689e417f
VP
668our @a;
669my @b;
670@a = reverse @a;
671@b = reverse @b;
672();
06fc6867 673####
507a68aa 674# #71870 Use of uninitialized value in bitwise and B::Deparse
06fc6867
VP
675my($r, $s, @a);
676@a = split(/foo/, $s, 0);
677$r = qr/foo/;
678@a = split(/$r/, $s, 0);
679();
98a1a137 680####
507a68aa 681# package declaration before label
98a1a137
Z
682{
683 package Foo;
684 label: print 123;
685}
538f5756 686####
507a68aa 687# shift optimisation
538f5756
RZ
688shift;
689>>>>
690shift();
691####
507a68aa 692# shift optimisation
538f5756
RZ
693shift @_;
694####
507a68aa 695# shift optimisation
538f5756
RZ
696pop;
697>>>>
698pop();
699####
507a68aa 700# shift optimisation
538f5756 701pop @_;
a539498a 702####
507a68aa 703#[perl #20444]
a539498a
FC
704"foo" =~ (1 ? /foo/ : /bar/);
705"foo" =~ (1 ? y/foo// : /bar/);
706"foo" =~ (1 ? s/foo// : /bar/);
707>>>>
708'foo' =~ ($_ =~ /foo/);
709'foo' =~ ($_ =~ tr/fo//);
710'foo' =~ ($_ =~ s/foo//);
e0ab66ad
NC
711####
712# Test @threadsv_names under 5005threads
713foreach $' (1, 2) {
714 sleep $';
715}
e7afc405
FC
716####
717# y///r
718tr/a/b/r;
cb8157e3
FC
719####
720# y/uni/code/
721tr/\x{345}/\x{370}/;
cb8578ff
FC
722####
723# [perl #90898]
724glob('a,');
09dcfa7d
FC
725####
726# [perl #91008]
727each $@;
728keys $~;
729values $!;
5d8c42c2
FC
730####
731# readpipe with complex expression
732readpipe $a + $b;