This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test require override with Deparse [perl #62500]
[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
640d5d41
FC
173# [perl #33752]
174{
175 my $code = <<"EOCODE";
176{
177 our \$\x{1e1f}\x{14d}\x{14d};
178}
179EOCODE
180 my $deparsed
181 = $deparse->coderef2text(eval "sub { our \$\x{1e1f}\x{14d}\x{14d} }" );
182 s/$ \n//x for $deparsed, $code;
183 is $deparsed, $code, 'our $funny_Unicode_chars';
184}
185
bdabb2d5
FC
186# [perl #62500]
187$a =
188 `$^X $path "-MO=Deparse" -e "BEGIN{*CORE::GLOBAL::require=sub{1}}" 2>&1`;
189$a =~ s/-e syntax OK\n//g;
190is($a, <<'EOCODF', "CORE::GLOBAL::require override causing panick");
191sub BEGIN {
192 *CORE::GLOBAL::require = sub {
193 1;
194 }
195 ;
196}
197EOCODF
198
507a68aa
NC
199done_testing();
200
ad46c0be 201__DATA__
507a68aa 202# A constant
ad46c0be
RH
2031;
204####
507a68aa 205# Constants in a block
ad46c0be
RH
206{
207 no warnings;
208 '???';
209 2;
210}
211####
507a68aa 212# Lexical and simple arithmetic
ad46c0be
RH
213my $test;
214++$test and $test /= 2;
215>>>>
216my $test;
217$test /= 2 if ++$test;
218####
507a68aa 219# list x
ad46c0be
RH
220-((1, 2) x 2);
221####
507a68aa 222# lvalue sub
ad46c0be
RH
223{
224 my $test = sub : lvalue {
225 my $x;
226 }
227 ;
228}
229####
507a68aa 230# method
ad46c0be
RH
231{
232 my $test = sub : method {
233 my $x;
234 }
235 ;
236}
237####
507a68aa 238# block with continue
87a42246 239{
ad46c0be 240 234;
f99a63a2 241}
ad46c0be
RH
242continue {
243 123;
87a42246 244}
ce4e655d 245####
507a68aa 246# lexical and package scalars
ce4e655d
RH
247my $x;
248print $main::x;
249####
507a68aa 250# lexical and package arrays
ce4e655d
RH
251my @x;
252print $main::x[1];
14a55f98 253####
507a68aa 254# lexical and package hashes
14a55f98
RH
255my %x;
256$x{warn()};
ad8caead 257####
507a68aa 258# <>
ad8caead
RGS
259my $foo;
260$_ .= <ARGV> . <$foo>;
cef22867 261####
507a68aa 262# \x{}
11454c59 263my $foo = "Ab\x{100}\200\x{200}\237Cd\000Ef\x{1000}\cA\x{2000}\cZ";
4ae52e81 264####
507a68aa 265# s///e
4ae52e81 266s/x/'y';/e;
241416b8 267####
507a68aa 268# block
241416b8
DM
269{ my $x; }
270####
507a68aa 271# while 1
241416b8
DM
272while (1) { my $k; }
273####
507a68aa 274# trailing for
241416b8
DM
275my ($x,@a);
276$x=1 for @a;
277>>>>
278my($x, @a);
0bb5f065 279$x = 1 foreach (@a);
241416b8 280####
507a68aa 281# 2 arguments in a 3 argument for
241416b8
DM
282for (my $i = 0; $i < 2;) {
283 my $z = 1;
284}
285####
507a68aa 286# 3 argument for
241416b8
DM
287for (my $i = 0; $i < 2; ++$i) {
288 my $z = 1;
289}
290####
507a68aa 291# 3 argument for again
241416b8
DM
292for (my $i = 0; $i < 2; ++$i) {
293 my $z = 1;
294}
295####
507a68aa 296# while/continue
241416b8
DM
297my $i;
298while ($i) { my $z = 1; } continue { $i = 99; }
299####
507a68aa 300# foreach with my
09d856fb 301foreach my $i (1, 2) {
241416b8
DM
302 my $z = 1;
303}
304####
507a68aa 305# foreach
241416b8
DM
306my $i;
307foreach $i (1, 2) {
308 my $z = 1;
309}
310####
507a68aa 311# foreach, 2 mys
241416b8
DM
312my $i;
313foreach my $i (1, 2) {
314 my $z = 1;
315}
316####
507a68aa 317# foreach
241416b8
DM
318foreach my $i (1, 2) {
319 my $z = 1;
320}
321####
507a68aa 322# foreach with our
241416b8
DM
323foreach our $i (1, 2) {
324 my $z = 1;
325}
326####
507a68aa 327# foreach with my and our
241416b8
DM
328my $i;
329foreach our $i (1, 2) {
330 my $z = 1;
331}
3ac6e0f9 332####
507a68aa 333# reverse sort
3ac6e0f9
RGS
334my @x;
335print reverse sort(@x);
336####
507a68aa 337# sort with cmp
3ac6e0f9
RGS
338my @x;
339print((sort {$b cmp $a} @x));
340####
507a68aa 341# reverse sort with block
3ac6e0f9
RGS
342my @x;
343print((reverse sort {$b <=> $a} @x));
36d57d93 344####
507a68aa 345# foreach reverse
36d57d93
RGS
346our @a;
347print $_ foreach (reverse @a);
aae53c41 348####
507a68aa 349# foreach reverse (not inplace)
aae53c41
RGS
350our @a;
351print $_ foreach (reverse 1, 2..5);
f86ea535 352####
507a68aa 353# bug #38684
f86ea535
SM
354our @ary;
355@ary = split(' ', 'foo', 0);
31c6271a 356####
507a68aa 357# bug #40055
31c6271a
RD
358do { () };
359####
507a68aa 360# bug #40055
31c6271a 361do { my $x = 1; $x };
d9002312 362####
507a68aa 363# <20061012113037.GJ25805@c4.convolution.nl>
d9002312
SM
364my $f = sub {
365 +{[]};
366} ;
8b2d6640 367####
507a68aa 368# bug #43010
8b2d6640
FC
369'!@$%'->();
370####
507a68aa 371# bug #43010
8b2d6640
FC
372::();
373####
507a68aa 374# bug #43010
8b2d6640
FC
375'::::'->();
376####
507a68aa 377# bug #43010
8b2d6640 378&::::;
09d856fb 379####
507a68aa 380# variables as method names
09d856fb
CK
381my $bar;
382'Foo'->$bar('orz');
383####
507a68aa 384# constants as method names
09d856fb
CK
385'Foo'->bar('orz');
386####
507a68aa 387# constants as method names without ()
09d856fb 388'Foo'->bar;
0ced6c29 389####
e9c69003 390# SKIP ?$] < 5.010 && "say not implemented on this Perl version"
507a68aa 391# say
7ddd1a01
NC
392say 'foo';
393####
e9c69003 394# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
507a68aa 395# state vars
0ced6c29
RGS
396state $x = 42;
397####
e9c69003 398# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
507a68aa 399# state var assignment
7ddd1a01
NC
400{
401 my $y = (state $x = 42);
402}
403####
e9c69003 404# SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
c4a6f826 405# state vars in anonymous subroutines
7ddd1a01
NC
406$a = sub {
407 state $x;
408 return $x++;
409}
410;
644741fd
NC
411####
412# SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
507a68aa 413# each @array;
644741fd
NC
414each @ARGV;
415each @$a;
416####
417# SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
507a68aa 418# keys @array; values @array
644741fd
NC
419keys @$a if keys @ARGV;
420values @ARGV if values @$a;
35925e80 421####
507a68aa 422# Anonymous arrays and hashes, and references to them
35925e80
RGS
423my $a = {};
424my $b = \{};
425my $c = [];
426my $d = \[];
9210de83
FR
427####
428# SKIP ?$] < 5.010 && "smartmatch and given/when not implemented on this Perl version"
507a68aa 429# implicit smartmatch in given/when
9210de83
FR
430given ('foo') {
431 when ('bar') { continue; }
432 when ($_ ~~ 'quux') { continue; }
433 default { 0; }
434}
7ecdd211 435####
507a68aa 436# conditions in elsifs (regression in change #33710 which fixed bug #37302)
7ecdd211
PJ
437if ($a) { x(); }
438elsif ($b) { x(); }
439elsif ($a and $b) { x(); }
440elsif ($a or $b) { x(); }
441else { x(); }
03b22f1b 442####
507a68aa 443# interpolation in regexps
03b22f1b
RGS
444my($y, $t);
445/x${y}z$t/;
227375e1 446####
4a4b8592 447# TODO new undocumented cpan-bug #33708
507a68aa 448# cpan-bug #33708
227375e1
RU
449%{$_ || {}}
450####
4a4b8592 451# TODO hash constants not yet fixed
507a68aa 452# cpan-bug #33708
227375e1
RU
453use constant H => { "#" => 1 }; H->{"#"}
454####
4a4b8592 455# TODO optimized away 0 not yet fixed
507a68aa 456# cpan-bug #33708
227375e1 457foreach my $i (@_) { 0 }
edbe35ea 458####
507a68aa 459# tests with not, not optimized
07f3cdf5 460my $c;
edbe35ea
VP
461x() unless $a;
462x() if not $a and $b;
463x() if $a and not $b;
464x() unless not $a and $b;
465x() unless $a and not $b;
466x() if not $a or $b;
467x() if $a or not $b;
468x() unless not $a or $b;
469x() unless $a or not $b;
07f3cdf5
VP
470x() if $a and not $b and $c;
471x() if not $a and $b and not $c;
472x() unless $a and not $b and $c;
473x() unless not $a and $b and not $c;
474x() if $a or not $b or $c;
475x() if not $a or $b or not $c;
476x() unless $a or not $b or $c;
477x() unless not $a or $b or not $c;
edbe35ea 478####
507a68aa 479# tests with not, optimized
07f3cdf5 480my $c;
edbe35ea
VP
481x() if not $a;
482x() unless not $a;
483x() if not $a and not $b;
484x() unless not $a and not $b;
485x() if not $a or not $b;
486x() unless not $a or not $b;
07f3cdf5
VP
487x() if not $a and not $b and $c;
488x() unless not $a and not $b and $c;
489x() if not $a or not $b or $c;
490x() unless not $a or not $b or $c;
491x() if not $a and not $b and not $c;
492x() unless not $a and not $b and not $c;
493x() if not $a or not $b or not $c;
494x() unless not $a or not $b or not $c;
495x() unless not $a or not $b or not $c;
edbe35ea 496>>>>
07f3cdf5 497my $c;
edbe35ea
VP
498x() unless $a;
499x() if $a;
500x() unless $a or $b;
501x() if $a or $b;
502x() unless $a and $b;
07f3cdf5
VP
503x() if $a and $b;
504x() if not $a || $b and $c;
505x() unless not $a || $b and $c;
506x() if not $a && $b or $c;
507x() unless not $a && $b or $c;
508x() unless $a or $b or $c;
509x() if $a or $b or $c;
510x() unless $a and $b and $c;
511x() if $a and $b and $c;
512x() unless not $a && $b && $c;
71c4dbc3 513####
507a68aa 514# tests that should be constant folded
71c4dbc3
VP
515x() if 1;
516x() if GLIPP;
517x() if !GLIPP;
518x() if GLIPP && GLIPP;
519x() if !GLIPP || GLIPP;
520x() if do { GLIPP };
521x() if do { no warnings 'void'; 5; GLIPP };
522x() if do { !GLIPP };
523if (GLIPP) { x() } else { z() }
524if (!GLIPP) { x() } else { z() }
525if (GLIPP) { x() } elsif (GLIPP) { z() }
526if (!GLIPP) { x() } elsif (GLIPP) { z() }
527if (GLIPP) { x() } elsif (!GLIPP) { z() }
528if (!GLIPP) { x() } elsif (!GLIPP) { z() }
529if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (GLIPP) { t() }
530if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
531if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
532>>>>
533x();
534x();
535'???';
536x();
537x();
538x();
539x();
540do {
541 '???'
542};
543do {
544 x()
545};
546do {
547 z()
548};
549do {
550 x()
551};
552do {
553 z()
554};
555do {
556 x()
557};
558'???';
559do {
560 t()
561};
562'???';
563!1;
564####
719c50dc
RGS
565# TODO constant deparsing has been backed out for 5.12
566# XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
507a68aa 567# tests that shouldn't be constant folded
ac0f1413
NC
568# It might be fundamentally impossible to make this work on ithreads, in which
569# case the TODO should become a SKIP
71c4dbc3
VP
570x() if $a;
571if ($a == 1) { x() } elsif ($b == 2) { z() }
572if (do { foo(); GLIPP }) { x() }
573if (do { $a++; GLIPP }) { x() }
574>>>>
575x() if $a;
576if ($a == 1) { x(); } elsif ($b == 2) { z(); }
2990415a
FR
577if (do { foo(); GLIPP }) { x(); }
578if (do { ++$a; GLIPP }) { x(); }
579####
0fa4a265 580# TODO constant deparsing has been backed out for 5.12
507a68aa 581# tests for deparsing constants
2990415a
FR
582warn PI;
583####
0fa4a265 584# TODO constant deparsing has been backed out for 5.12
507a68aa 585# tests for deparsing imported constants
3779476a 586warn O_TRUNC;
2990415a 587####
0fa4a265 588# TODO constant deparsing has been backed out for 5.12
507a68aa 589# tests for deparsing re-exported constants
2990415a
FR
590warn O_CREAT;
591####
0fa4a265 592# TODO constant deparsing has been backed out for 5.12
507a68aa 593# tests for deparsing imported constants that got deleted from the original namespace
aaf9c2b2 594warn O_APPEND;
2990415a 595####
0fa4a265
DM
596# TODO constant deparsing has been backed out for 5.12
597# XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
507a68aa 598# tests for deparsing constants which got turned into full typeglobs
ac0f1413
NC
599# It might be fundamentally impossible to make this work on ithreads, in which
600# case the TODO should become a SKIP
2990415a
FR
601warn O_EXCL;
602eval '@Fcntl::O_EXCL = qw/affe tiger/;';
603warn O_EXCL;
604####
0fa4a265 605# TODO constant deparsing has been backed out for 5.12
507a68aa 606# tests for deparsing of blessed constant with overloaded numification
2990415a 607warn OVERLOADED_NUMIFICATION;
79289e05
NC
608####
609# TODO Only strict 'refs' currently supported
507a68aa 610# strict
79289e05
NC
611no strict;
612$x;
613####
614# TODO Subsets of warnings could be encoded textually, rather than as bitflips.
507a68aa 615# subsets of warnings
79289e05
NC
616no warnings 'deprecated';
617my $x;
618####
619# TODO Better test for CPAN #33708 - the deparsed code has different behaviour
507a68aa 620# CPAN #33708
79289e05
NC
621use strict;
622no warnings;
623
624foreach (0..3) {
625 my $x = 2;
626 {
627 my $x if 0;
628 print ++$x, "\n";
629 }
630}
d83f38d8 631####
507a68aa 632# no attribute list
d83f38d8
NC
633my $pi = 4;
634####
2dc78664
NC
635# SKIP ?$] > 5.013006 && ":= is now a syntax error"
636# := treated as an empty attribute list
d83f38d8
NC
637no warnings;
638my $pi := 4;
639>>>>
640no warnings;
641my $pi = 4;
642####
507a68aa 643# : = empty attribute list
d83f38d8
NC
644my $pi : = 4;
645>>>>
646my $pi = 4;
689e417f 647####
507a68aa 648# in place sort
689e417f
VP
649our @a;
650my @b;
651@a = sort @a;
652@b = sort @b;
653();
654####
507a68aa 655# in place reverse
689e417f
VP
656our @a;
657my @b;
658@a = reverse @a;
659@b = reverse @b;
660();
06fc6867 661####
507a68aa 662# #71870 Use of uninitialized value in bitwise and B::Deparse
06fc6867
VP
663my($r, $s, @a);
664@a = split(/foo/, $s, 0);
665$r = qr/foo/;
666@a = split(/$r/, $s, 0);
667();
98a1a137 668####
507a68aa 669# package declaration before label
98a1a137
Z
670{
671 package Foo;
672 label: print 123;
673}
538f5756 674####
507a68aa 675# shift optimisation
538f5756
RZ
676shift;
677>>>>
678shift();
679####
507a68aa 680# shift optimisation
538f5756
RZ
681shift @_;
682####
507a68aa 683# shift optimisation
538f5756
RZ
684pop;
685>>>>
686pop();
687####
507a68aa 688# shift optimisation
538f5756 689pop @_;
a539498a 690####
507a68aa 691#[perl #20444]
a539498a
FC
692"foo" =~ (1 ? /foo/ : /bar/);
693"foo" =~ (1 ? y/foo// : /bar/);
694"foo" =~ (1 ? s/foo// : /bar/);
695>>>>
696'foo' =~ ($_ =~ /foo/);
697'foo' =~ ($_ =~ tr/fo//);
698'foo' =~ ($_ =~ s/foo//);
e0ab66ad
NC
699####
700# Test @threadsv_names under 5005threads
701foreach $' (1, 2) {
702 sleep $';
703}
e7afc405
FC
704####
705# y///r
706tr/a/b/r;
cb8157e3
FC
707####
708# y/uni/code/
709tr/\x{345}/\x{370}/;
cb8578ff
FC
710####
711# [perl #90898]
712glob('a,');
09dcfa7d
FC
713####
714# [perl #91008]
715each $@;
716keys $~;
717values $!;
5d8c42c2
FC
718####
719# readpipe with complex expression
720readpipe $a + $b;