blib/lib/POSIX/1003/Sysconf.pm

filter: Statementstmt 89.7% 35 / 39 Branchbran 33.3% 2 / 6 Conditioncond 62.5% 5 / 8 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 90.9% 10 / 11 Podpod 100% 3 / 3 totaltotal 78.8% 56 / 71 CC 8 SCAR 14.1
CC
8
Cov
79%
exampleValue
12.0
sysconf
5.1
_create_constant
2.0
CRAP 4.1
« lists.PL ↑ Summary blib/lib/POSIX/1003/Confstr.pm »
1 # Copyrights 2011-2020 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.02.
5 # This code is part of distribution POSIX-1003. Meta-POD processed with
6 # OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package POSIX::1003::Sysconf;
10 5 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 $VERSION = '1.02';
12  
13 5 ▶use base 'POSIX::1003::Module';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 5 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 5 my @constants;
21 5 my @functions = qw/sysconf sysconf_names/;
22  
23 5 our %EXPORT_TAGS =
24 ( constants => \@constants
25 , functions => \@functions
26 , tables => [ '%sysconf' ]
27 );
28  
29 5 my $sysconf;
30 5 our %sysconf;
31  
32 5 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
33 5 $sysconf = sysconf_table;
34 5 push @constants, keys %$sysconf;
35 5 tie %sysconf, 'POSIX::1003::ReadOnlyTable', $sysconf;
36 }
37  
38 sub sysconf($);
39  
40  
41 sub exampleValue($)
42 0 ▶{ my ($class, $name) = @_;
Subroutine exampleValue: not called CC=3 SCAR=24.8
Pod documented
43 0 ▶ $name =~ m/^_SC_/ or return;
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /^_SC_/ or return 0 0 0
44 0 my $val = sysconf $name;
45 0 ▶ defined $val ? $val : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 0 0 0
46 }
47  
48  
49 sub sysconf($)
50 219 ▶{ my $key = shift // return;
Subroutine sysconf: called CC=5 SCAR=16.3
Pod documented
Condition50%1/2
shift() // (return)
l!l
2190
MC/DC0%0/1
shift() // (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
51 219 ▶ $key =~ /^_SC_/
Branch: 1 branch
BranchTrueFalseTotal
$key =~ /^_SC_/ or croak("pass the constant name as string") 217 2 219
52 or croak "pass the constant name as string";
53
54 217 ▶ my $id = $sysconf->{$key} // return;
Condition50%1/2
$sysconf->{$key} // (return)
l!l
2170
MC/DC0%0/1
$sysconf->{$key} // (return)
$sysconf->{$key}
Truth table50%1/2
A
A= $sysconf->{$key}
Aresult
11
00
55 217 ▶ my $val = POSIX::sysconf($id) // return;
Condition100%2/2
POSIX::sysconf($id) // (return)
l!l
13483
MC/DC100%1/1
POSIX::sysconf($id) // (return)
POSIX::sysconf($id)
Truth table100%2/2
A
A= POSIX::sysconf($id)
Aresult
11
00
56 134 $val+0; # remove " but true" from "0"
57 }
58  
59 sub _create_constant($)
60 1 ▶{ my ($class, $name) = @_;
Subroutine _create_constant: called CC=2 SCAR=7.0
61 1 ▶ my $id = $sysconf->{$name} // return sub() {undef};
Condition50%1/2
$sysconf->{$name} // (return sub () { undef } )
l!l
10
MC/DC0%0/1
$sysconf->{$name} // (return sub () { undef } )
$sysconf->{$name}
Truth table50%1/2
A
A= $sysconf->{$name}
Aresult
11
00
62 1 ▶ sub() {POSIX::sysconf($id)};
Subroutine __ANON__: called CC=1 SCAR=0.0
63 }
64  
65  
66 1 ▶sub sysconf_names() { keys %$sysconf }
Subroutine sysconf_names: called CC=1 SCAR=0.0
Pod documented
67  
68  
69 5 1;
« lists.PL ↑ Summary blib/lib/POSIX/1003/Confstr.pm »