issue96.t 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #plan tests => 3;
  11. plan skip_all => 'defined &gv optimization temp. disabled'; exit;
  12. my $script = 'defined(&B::OP::name) && print q(ok)';
  13. sub compile_check {
  14. my ($num,$b,$base,$script,$cmt) = @_;
  15. my $name = $base."_$num";
  16. unlink("$name.c", "$name.pl");
  17. open F, ">", "$name.pl";
  18. print F $script;
  19. close F;
  20. my $X = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
  21. my ($result,$out,$stderr) =
  22. run_cmd("$X -Iblib/arch -Iblib/lib -MO=$b,-o$name.c $name.pl", 20);
  23. unless (-e "$name.c") {
  24. print "not ok $num # $name B::$b failed\n";
  25. exit;
  26. }
  27. # check stderr for "blocking not found"
  28. #diag length $stderr," ",length $out;
  29. if (!$stderr and $out) {
  30. $stderr = $out;
  31. }
  32. $stderr =~ s/main::stderr.*//s;
  33. like($stderr,qr/skip saving defined\(&B::OP::name\)/, "detect defined(&B::OP::name)");
  34. like($stderr,qr/GV::save \*B::OP::name done/, "should save *B::OP::name");
  35. unlike($stderr,qr/GV::save &B::OP::name/, "should not save &B::OP::name");
  36. }
  37. compile_check(1,'C,-O3,-DGC','ccode96i',$script,"");