issue95.t 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=95
  3. # methods not found. see t/testc.sh -DCsP,-v -O0 95
  4. use strict;
  5. BEGIN {
  6. unshift @INC, 't';
  7. require "test.pl";
  8. }
  9. use Test::More;
  10. eval "use IO::Socket::SSL";
  11. if ($@) {
  12. plan skip_all => "IO::Socket::SSL required for testing issue95" ;
  13. } else {
  14. plan tests => 5;
  15. }
  16. my $issue = <<'EOF';
  17. use IO::Socket::INET ();
  18. use IO::Socket::SSL ('inet4');
  19. use Net::SSLeay ();
  20. use IO ();
  21. use Socket ();
  22. my $handle = new IO::Socket::SSL;
  23. $handle->blocking(0);
  24. print "ok";
  25. EOF
  26. my $typed = <<'EOF';
  27. use IO::Socket::SSL();
  28. my IO::Socket::SSL $handle = new IO::Socket::SSL;
  29. $handle->blocking(0);
  30. print "ok";
  31. EOF
  32. sub compile_check {
  33. my ($num,$b,$base,$script,$cmt) = @_;
  34. my $name = $base."_$num";
  35. unlink("$name.c", "$name.pl");
  36. open F, ">", "$name.pl";
  37. print F $script;
  38. close F;
  39. my $X = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
  40. $b .= ',-DCsp,-v';
  41. my ($result,$out,$stderr) =
  42. run_cmd("$X -Iblib/arch -Iblib/lib -MO=$b,-o$name.c $name.pl", 20);
  43. unless (-e "$name.c") {
  44. print "not ok $num # $name B::$b failed\n";
  45. exit;
  46. }
  47. # check stderr for "blocking not found"
  48. #diag length $stderr," ",length $out;
  49. if (!$stderr and $out) {
  50. $stderr = $out;
  51. }
  52. my $notfound = $stderr =~ /blocking not found/;
  53. ok(!$notfound, $cmt);
  54. # check stderr for "save package_pv "blocking" for method_name"
  55. my $found = $stderr =~ /save package_pv "blocking" for method_name/;
  56. TODO: {
  57. local $TODO = "wrong package_pv blocking";
  58. ok(!$found, $cmt);
  59. }
  60. }
  61. compile_check(1,'C,-O3,-UB','ccode95i',$issue,"IO::Socket::blocking method found in \@ISA");
  62. compile_check(2,'C,-O3,-UB','ccode95i',$typed,'typed');
  63. ctestok(3,'C,-O3,-UB','ccode95i',$issue,'TODO run');