This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[rt.cpan.org #61577] try to populate socket info when not cached
[perl5.git] / dist / IO / t / cachepropagate-udp.t
CommitLineData
93a5d7bf
TC
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use IO::Socket;
7use IO::Socket::INET;
8use Socket;
9use Test::More;
10
11plan tests => 7;
12
13my $listener = IO::Socket::INET->new(LocalAddr => '127.0.0.1',
14 Proto => 'udp');
15ok(defined($listener), 'socket created');
16
17my $p = $listener->protocol();
18ok(defined($p), 'protocol defined');
19my $d = $listener->sockdomain();
20ok(defined($d), 'domain defined');
21my $s = $listener->socktype();
22ok(defined($s), 'type defined');
23
24my $new = IO::Socket::INET->new_from_fd($listener->fileno(), 'r+');
25
93a5d7bf
TC
26is($new->sockdomain(), $d, 'domain match');
27SKIP: {
28 skip "no Socket::SO_PROTOCOL", 1 if !defined(eval { Socket::SO_PROTOCOL });
29 is($new->protocol(), $p, 'protocol match');
30}
31SKIP: {
32 skip "no Socket::SO_TYPE", 1 if !defined(eval { Socket::SO_TYPE });
33 is($new->socktype(), $s, 'type match');
34}