issue96.t 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=96
  3. # defined &gv should not store the gv->CV
  4. use strict;
  5. BEGIN {
  6. unshift @INC, 't';
  7. require "test.pl";
  8. }
  9. use Test::More;
  10. use Config;
  11. plan tests => 3;
  12. #plan skip_all => 'defined &gv optimization temp. disabled'; exit;
  13. my $ITHREADS = $Config{useithreads};
  14. my $script = 'defined(&B::OP::name) || print q(ok)';
  15. sub compile_check {
  16. my ($num,$b,$base,$script,$cmt) = @_;
  17. my $name = $base."_$num";
  18. unlink("$name.c", "$name.pl");
  19. open F, ">", "$name.pl";
  20. print F $script;
  21. close F;
  22. my $X = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
  23. my ($result,$out,$stderr) =
  24. run_cmd("$X -Iblib/arch -Iblib/lib -MO=$b,-o$name.c $name.pl", 20);
  25. unless (-e "$name.c") {
  26. print "not ok $num # $name B::$b failed\n";
  27. exit;
  28. }
  29. # check stderr for "blocking not found"
  30. #diag length $stderr," ",length $out;
  31. if (!$stderr and $out) {
  32. $stderr = $out;
  33. }
  34. $stderr =~ s/main::stderr.*//s;
  35. if ($ITHREADS) { # padop, not gvop
  36. like($stderr,qr/skip saving defined\(&/, "detect defined(&B::OP::name)");
  37. ok(1, "#skip save *B::OP::name with padop threads");
  38. } else {
  39. like($stderr,qr/skip saving defined\(&B::OP::name\)/, "detect defined(&B::OP::name)");
  40. like($stderr,qr/GV::save \*B::OP::name done/, "should save *B::OP::name");
  41. }
  42. unlike($stderr,qr/GV::save &B::OP::name/, "should not save &B::OP::name");
  43. }
  44. compile_check(1,'C,-O3,-DGC','ccode96i',$script,"");