File Coverage

lib/POSIX/1003/Errno.pm
Criterion Covered Total %
statement 26 31 83.8
branch 3 6 50.0
condition 2 6 33.3
subroutine 10 13 76.9
pod 4 4 100.0
total 45 60 75.0


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 6     6   16844 use warnings;
  6         6  
  6         162  
6 6     6   20 use strict;
  6         6  
  6         187  
7              
8             package POSIX::1003::Errno;
9 6     6   31 use vars '$VERSION';
  6         7  
  6         240  
10             $VERSION = '0.99_06';
11              
12 6     6   21 use base 'POSIX::1003::Module';
  6         11  
  6         772  
13              
14 6     6   26 use Carp 'croak';
  6         7  
  6         1411  
15              
16             my @constants;
17             my @functions = qw/strerror errno errno_names/;
18              
19             our %EXPORT_TAGS =
20             ( constants => \@constants
21             , functions => \@functions
22             , tables => [ '%errno' ]
23             );
24              
25             my $errno;
26             our %errno;
27              
28             BEGIN {
29 6     6   359 $errno = errno_table;
30 6         215 push @constants, keys %$errno;
31 6         52 tie %errno, 'POSIX::1003::ReadOnlyTable', $errno;
32             }
33              
34             sub errno($);
35              
36              
37             sub exampleValue($)
38 0     0 1 0 { my ($class, $name) = @_;
39 0 0       0 $name =~ m/^(?:WSA)?E/ or return;
40 0   0     0 errno($name) // 'undef';
41             }
42              
43              
44 134 50   134 1 479 sub strerror($) { _strerror($_[0]) || "Unknown error $_[0]" }
45              
46              
47             sub errno($)
48 137   50 137 1 1468 { my $key = shift // return;
49 137 100       633 $key =~ /^(?:WSA)?E/
50             or croak "pass the constant name $key as string";
51            
52 135         186 $errno->{$key};
53             }
54              
55             sub _create_constant($)
56 6     6   10 { my ($class, $name) = @_;
57 6   50 0   44 my $nr = $errno->{$name} // return sub() {undef};
  0         0  
58 6     0   43 sub() {$nr};
  0         0  
59             }
60              
61              
62 1     1 1 454 sub errno_names() { keys %$errno }
63              
64              
65             1;