File Coverage

lib/POSIX/1003/Confstr.pm
Criterion Covered Total %
statement 27 32 84.3
branch 2 6 33.3
condition 3 6 50.0
subroutine 10 12 83.3
pod 3 3 100.0
total 45 59 76.2


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 3     3   14592 use warnings;
  3         4  
  3         84  
6 3     3   13 use strict;
  3         4  
  3         112  
7              
8             package POSIX::1003::Confstr;
9 3     3   9 use vars '$VERSION';
  3         3  
  3         123  
10             $VERSION = '0.99_06';
11              
12 3     3   11 use base 'POSIX::1003::Module';
  3         5  
  3         399  
13              
14 3     3   16 use Carp 'croak';
  3         4  
  3         381  
15              
16             my @constants;
17             my @functions = qw/confstr confstr_names/;
18              
19             our %EXPORT_TAGS =
20             ( constants => \@constants
21             , functions => \@functions
22             , tables => [ '%confstr' ]
23             );
24              
25             my $confstr;
26             our %confstr;
27             sub confstr($);
28              
29             BEGIN {
30 3     3   113 $confstr = confstr_table;
31 3         33 push @constants, keys %$confstr;
32 3         18 tie %confstr, 'POSIX::1003::ReadOnlyTable', $confstr;
33             }
34              
35              
36             sub exampleValue($)
37 0     0 1 0 { my ($class, $name) = @_;
38 0 0       0 $name =~ m/^_CS_/ or return;
39 0         0 my $val = confstr $name;
40 0 0       0 defined $val ? "'$val'" : 'undef';
41             }
42              
43             #-----------------------
44              
45             sub confstr($)
46 68   50 68 1 660 { my $key = shift // return;
47 68 100       352 $key =~ /^_CS_/
48             or croak "pass the constant name as string";
49              
50 66   50     87 my $id = $confstr->{$key} // return;
51 66         238 _confstr($id);
52             }
53              
54             sub _create_constant($)
55 1     1   2 { my ($class, $name) = @_;
56 1   50 0   5 my $id = $confstr->{$name} // return sub() {undef};
  0         0  
57 1     2   4 sub() {_confstr($id)};
  2         691  
58             }
59              
60             #--------------------------
61              
62 1     1 1 417 sub confstr_names() { keys %$confstr }
63              
64             #--------------------------
65              
66             1;