This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
The Grand Trek: move the *.t files from t/ to lib/ and ext/.
[perl5.git] / lib / Net / servent.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6 }
7
8 BEGIN {
9     our $hasse;
10     eval { my @n = getservbyname "echo", "tcp" };
11     $hasse = 1 unless $@ && $@ =~ /unimplemented/;
12     unless ($hasse) { print "1..0 # Skip: no getservbyname\n"; exit 0 }
13     use Config;
14     $hasse = 0 unless $Config{'i_netdb'} eq 'define';
15     unless ($hasse) { print "1..0 # Skip: no netdb.h\n"; exit 0 }
16 }
17
18 BEGIN {
19     our @servent = getservbyname "echo", "tcp"; # This is the function getservbyname.
20     unless (@servent) { print "1..0 # Skip: no echo service\n"; exit 0 }
21 }
22
23 print "1..3\n";
24
25 use Net::servent;
26
27 print "ok 1\n";
28
29 my $servent = getservbyname "echo", "tcp"; # This is the OO getservbyname.
30
31 print "not " unless $servent->name   eq $servent[0];
32 print "ok 2\n";
33
34 print "not " unless $servent->port  == $servent[2];
35 print "ok 3\n";
36
37 # Testing pretty much anything else is unportable.
38