sv_2pv_flags and ROK and UTF8 flags
[p5sagit/p5-mst-13.2.git] / lib / Net / t / config.t
index 95a77aa..08df82b 100644 (file)
@@ -5,8 +5,48 @@ BEGIN {
        chdir 't' if -d 't';
        @INC = '../lib';
     }
+    if (!eval "require Socket") {
+       print "1..0 # no Socket\n"; exit 0;
+    }
+    undef *{Socket::inet_aton};
+    undef *{Socket::inet_ntoa};
+    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
+        print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
+    }
+    $INC{'Socket.pm'} = 1;
+}
+
+package Socket;
+
+sub import {
+       my $pkg = caller();
+       no strict 'refs';
+       *{ $pkg . '::inet_aton' } = \&inet_aton;
+       *{ $pkg . '::inet_ntoa' } = \&inet_ntoa;
+}
+
+my $fail = 0;
+my %names;
+
+sub set_fail {
+       $fail = shift;
+}
+
+sub inet_aton {
+       return if $fail;
+       my $num = unpack('N', pack('C*', split(/\./, $_[0])));
+       $names{$num} = $_[0];
+       return $num;
 }
 
+sub inet_ntoa {
+       return if $fail;
+       return $names{$_[0]};
+}
+
+package main;
+
+
 (my $libnet_t = __FILE__) =~ s/config.t/libnet_t.pl/;
 require $libnet_t;
 
@@ -16,14 +56,16 @@ use Net::Config;
 ok( exists $INC{'Net/Config.pm'}, 'Net::Config should have been used' );
 ok( keys %NetConfig, '%NetConfig should be imported' );
 
+Socket::set_fail(1);
 undef $NetConfig{'ftp_firewall'};
 is( Net::Config->requires_firewall(), 0, 
        'requires_firewall() should return 0 without ftp_firewall defined' );
 
 $NetConfig{'ftp_firewall'} = 1;
-is( Net::Config->requires_firewall(''), -1,
+is( Net::Config->requires_firewall('a.host.not.there'), -1,
        '... should return -1 without a valid hostname' );
 
+Socket::set_fail(0);
 delete $NetConfig{'local_netmask'};
 is( Net::Config->requires_firewall('127.0.0.1'), 0,
        '... should return 0 without local_netmask defined' );