issue95.t 1.9 KB

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