File Coverage

lib/POSIX/1003/Socket.pm
Criterion Covered Total %
statement 20 28 71.4
branch n/a
condition 0 4 0.0
subroutine 5 10 50.0
pod 2 2 100.0
total 27 44 61.3


line stmt bran cond sub pod time code
1             # Copyrights 2011-2015 by [Mark Overmeer].
2             # For other contributors see ChangeLog.
3             # See the manual pages for details on the licensing terms.
4             # Pod stripped from pm file by OODoc 2.01.
5 2     2   701 use warnings;
  2         4  
  2         60  
6 2     2   8 use strict;
  2         2  
  2         71  
7              
8             package POSIX::1003::Socket;
9 2     2   14 use vars '$VERSION';
  2         2  
  2         102  
10             $VERSION = '0.99_06';
11              
12 2     2   9 use base 'POSIX::1003::Module';
  2         2  
  2         529  
13              
14             my (@sock, @sol, @so, @af, @pf, @constants);
15             my @functions = qw/socket_names/;
16             our @IN_CORE = qw//; # to be added
17              
18             our %EXPORT_TAGS =
19             ( sock => \@sock
20             , so => \@so
21             , sol => \@sol
22             , af => \@af
23             , pf => \@pf
24             , constants => \@constants
25             , functions => \@functions
26             , tables => [ qw/%sockets/ ]
27             );
28              
29             my ($socket, %socket);
30             BEGIN {
31 2     2   305 $socket = socket_table;
32 2         260 @constants = sort keys %$socket;
33 2         25 tie %socket, 'POSIX::1003::ReadOnlyTable', $socket;
34              
35 2         64 @sock = grep /^SOCK/, @constants;
36 2         64 @so = grep /^SO_/, @constants;
37 2         56 @sol = grep /^SOL_/, @constants;
38 2         72 @af = grep /^AF_/, @constants;
39 2         318 @pf = grep /^PF_/, @constants;
40             }
41              
42              
43             sub exampleValue($)
44 0     0 1   { my ($class, $name) = @_;
45 0   0       $socket{$name} // 'undef';
46             }
47              
48             sub _create_constant($)
49 0     0     { my ($class, $name) = @_;
50 0   0 0     my $nr = $socket->{$name} // return sub() {undef};
  0            
51 0     0     sub() {$nr};
  0            
52             }
53              
54             #-------------
55              
56             # get/setsockopt in XS
57              
58             #------------
59              
60 0     0 1   sub socket_names() { keys %$socket }
61              
62             #------------
63              
64             1;