issue59.t 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=59
  3. # Problems compiling scripts that use IO::Socket
  4. use Test::More tests => 3;
  5. use strict;
  6. BEGIN {
  7. unshift @INC, 't';
  8. require "test.pl";
  9. }
  10. use Config;
  11. my $name = "ccode59i";
  12. my $script = <<'EOF';
  13. use strict;
  14. use warnings;
  15. use IO::Socket;
  16. my $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "perl.org", PeerPort => "80" );
  17. if ($remote) {
  18. print $remote "GET / HTTP/1.0" . "\r\n\r\n";
  19. my $result = <$remote>;
  20. $result =~ m|HTTP/1.1 200 OK| ? print "ok" : print $result;
  21. close $remote;
  22. }
  23. EOF
  24. open F, "> $name.pl";
  25. print F $script;
  26. close F;
  27. my $expected = "ok";
  28. my $runperl = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
  29. my $q = $] < 5.008001 ? "" : "-qq,";
  30. my $result = qx($runperl $name.pl);
  31. my $canconnect = $result eq $expected ? 1 : 0;
  32. my $cmt = "connect to http://perl.org:80 via IO::Socket";
  33. SKIP: {
  34. skip "cannot $cmt", 3 if !$canconnect;
  35. #skip "eats memory on 5.6", 2 if $] <= 5.008001;
  36. #skip "fails 5.14 threaded", 2
  37. # if $] > 5.014 and $] < 5.015 and $Config{'useithreads'} and (!-d ".git" or $ENV{NO_AUTHOR});
  38. plctestok(1, $name, $script, "BC $name ".$cmt);
  39. #$cmt = "TODO 5.14thr" if $] > 5.014 and $] < 5.015 and $Config{'useithreads'};
  40. #$cmt = "TODO >=5.16" if $] >= 5.016; # fixed with 1.45_04
  41. $cmt = "TODO <5.10" if $] < 5.010; # no idea why
  42. ctestok(2, "C", $name, $script, "C $name ".$cmt);
  43. ctestok(3, "CC", $name, $script, "CC $name ".$cmt);
  44. }