From: Robert Spier Date: Wed, 29 Nov 2000 02:17:49 +0000 (-0500) Subject: net_hostent.t (was Re: [ID 20001128.002] what's the point of example code if it is... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fedf0971c8ded0f79538029ca8454d5a1eb6ad25;p=p5sagit%2Fp5-mst-13.2.git net_hostent.t (was Re: [ID 20001128.002] what's the point of example code if it is buggy?) Message-ID: <14884.44445.760322.278647@localhost.localdomain> Add a test for Net::hostent. p4raw-id: //depot/perl@7920 --- diff --git a/t/lib/net-hostent.t b/t/lib/net-hostent.t new file mode 100644 index 0000000..3388a93 --- /dev/null +++ b/t/lib/net-hostent.t @@ -0,0 +1,41 @@ +#!./perl -w + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +BEGIN { $| = 1; print "1..5\n"; } + +END {print "not ok 1\n" unless $loaded;} + +use Net::hostent; + +$loaded = 1; +print "ok 1\n"; + +# test basic resolution of localhost <-> 127.0.0.1 +use Socket; + +my $h = gethost('localhost'); +my $i = gethostbyaddr(inet_aton("127.0.0.1")); + +print "not " if inet_ntoa($h->addr) ne "127.0.0.1"; +print "ok 2\n"; + +print "not " if inet_ntoa($i->addr) ne "127.0.0.1"; +print "ok 3\n"; + +# need to skip the name comparisons on Win32 because windows will +# return the name of the machine instead of "localhost" when resolving +# 127.0.0.1 or even "localhost" + +if ($^O eq 'MSWin32') { + print "ok $_ # skipped on win32\n" for (4,5); +} else { + print "not " if $h->name ne "localhost"; + print "ok 4\n"; + + print "not " if $i->name ne "localhost"; + print "ok 5\n"; +}