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