OO/Functions.pm

filter: Statementstmt 72.7% 56 / 77 Branchbran 57.6% 30 / 52 Conditioncond 80.0% 4 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 65.9% 95 / 144 CC 16 SCAR 31.6
CC
16
Cov
67%
import
33.3
__ANON__
20.0
__ANON__
2.0
CRAP 23.6
« OO/Error.pm ↑ Summary OO/X509/Name.pm »
1  
2 package Net::SSLeay::OO::Functions;
3  
4 5 ▶use Net::SSLeay;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 my %prefixes = (
7 "" => "Net::SSLeay::OO::SSL",
8 BIO => "Net::SSLeay::OO::BIO",
9 CIPHER => "Net::SSLeay::OO::Cipher",
10 COMP => "Net::SSLeay::OO::Compression",
11 CTX => "Net::SSLeay::OO::Context",
12 DH => "Net::SSLeay::OO::KeyType::DH",
13 ENGINE => "Net::SSLeay::OO::Engine",
14 ERR => "Net::SSLeay::OO::Error",
15 EVP_PKEY => "Net::SSLeay::OO::PrivateKey",
16  
17 #MD2 => undef,
18 #MD4 => undef,
19 #MD5 => undef,
20 PEM => "Net::SSLeay::OO::PEM",
21  
22 #P_ASN1_UTCTIME => undef,
23 RAND => "Net::SSLeay::OO::PRNG",
24 RSA => "Net::SSLeay::OO::KeyType::RSA",
25 SESSION => "Net::SSLeay::OO::Session",
26  
27 #X509V3_EXT => undef,
28 X509_NAME => "Net::SSLeay::OO::X509::Name",
29 X509_STORE => "Net::SSLeay::OO::X509::Store",
30 X509_STORE_CTX => "Net::SSLeay::OO::X509::Context",
31 X509 => "Net::SSLeay::OO::X509",
32 );
33  
34 5 my %ready;
35  
36 5 ▶while ( my ( $sym, $glob ) = each %Net::SSLeay:: ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %Net::SSLeay::) 4880 5 4885
37 4880 my $display = $sym =~ /ERRZX/;
38 4880 ▶ print STDERR "Considering $sym: " if $display;
Branch: 1 branch
BranchTrueFalseTotal
if $display 0 4880 4880
39 4880 my ( $sub_pkg, $method ) =
40 $sym =~ m{^(?:([A-Z][A-Z0-9]*(?:_[A-Z][A-Z0-9]*)*)_)?
41 ([a-z]\w+)$}x;
42 4880 ▶ if ( !$method ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($method) 995 3885 4880
43 995 ▶ print STDERR "didn't match pattern, next\n" if $display;
Branch: 1 branch
BranchTrueFalseTotal
if $display 0 995 995
44 995 next;
45 }
46 5 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 3885 ▶ if ( !*{"Net::SSLeay::$sym"}{CODE} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (*{"Net::SSLeay::$sym";}{"CODE"}) 35 3850 3885
48 35 ▶ print STDERR "not a func, next\n" if $display;
Branch: 1 branch
BranchTrueFalseTotal
if $display 0 35 35
49 35 next;
50 }
51 3850 ▶ if ( $method eq "new" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq "new") 75 3775 3850
52 75 ▶ print STDERR "it's 'new', next\n" if $display;
Branch: 1 branch
BranchTrueFalseTotal
if $display 0 75 75
53 75 next;
54 }
55 3775 ▶ my $pkg = $prefixes{ $sub_pkg || "" };
Condition100%2/2
$sub_pkg || ''
l!l
22901485
MC/DC100%1/1
$sub_pkg || ''
$sub_pkg
Truth table100%2/2
A
A= $sub_pkg
Aresult
11
00
56 3775 ▶ if ( !$pkg ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pkg) 860 2915 3775
57 860 ▶ print STDERR "destination package undefined; next\n"
Branch: 1 branch
BranchTrueFalseTotal
if $display 0 860 860
58 if $display;
59 860 next;
60 }
61 2915 ▶ print STDERR " => belongs in $pkg as $method\n" if $display;
Branch: 1 branch
BranchTrueFalseTotal
if $display 0 2915 2915
62 2915 ▶ if ( *{$glob}{CODE} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (*{$glob;}{'CODE'}) { } 2540 375 2915
63 2540 $ready{$pkg}{$method} = \&{*$glob};
64 }
65 else {
66 0 ▶ $ready{$pkg}{$method} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
67 0 goto \&{"Net::SSLeay::$sym"};
68 375 };
69 }
70 }
71  
72 14 ▶sub import {
Subroutine import: called CC=13 SCAR=35.0
73 14 my $pkg = shift;
74 14 my $caller = caller;
75 0 ▶ my $install = shift || sub {shift};
Subroutine __ANON__: not called CC=1 SCAR=0.6
Condition66%2/3
shift() || sub { shift(); }
l!l&&r!l&&!r
1040
MC/DC0%0/2
shift() || sub { shift(); }
shift() sub { shift(); }
Truth table66%2/3
A || B
A= shift()B= sub { shift(); }
ABresult
1X1
011
000
76 14 my %opts = @_;
77 14 my %exclude;
78 14 ▶ if ( my $aref = $opts{-exclude} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $aref = $opts{"-exclude"}) 0 14 14
79 0 ▶ die "usage: -exclude => [qw( func1 func2 )]"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $aref eq "ARRAY" 0 0 0
80 unless ref $aref eq "ARRAY";
81 0 %exclude = map { $_ => 1 } @$aref;
82 }
83 14 my %include;
84 14 ▶ if ( my $href = $opts{-include} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $href = $opts{"-include"}) 0 14 14
85 0 ▶ die "usage: -include => { foo_func => 'methname' }"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $href eq "HASH" 0 0 0
86 unless ref $href eq "HASH";
87 0 %include = %$href;
88 }
89 14 ▶ if ( !ref $install ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $install) 5 9 14
90 5 my $att = $install;
91 105 ▶ $install = sub {
Subroutine __ANON__: called CC=1 SCAR=4.4
92 105 my $code = shift;
93 105 my $method = shift;
94 0 ▶ sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
95 0 my $self = shift;
96 0 my @rv;
97 0 ▶ my $pointer = $self->$att
Branch: 1 branch
BranchTrueFalseTotal
my $pointer = $self->$att or die "no pointer in $self; this" . ' object may be being used outside of its valid lifetime' 0 0 0
98 or die "no pointer in $self; this"
99 . " object may be being used outside of its valid lifetime";
100 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
101 0 @rv = $code->( $pointer, @_ );
102 }
103 else {
104 0 $rv[0] = $code->( $pointer, @_ );
105 }
106 0 &Net::SSLeay::OO::Error::die_if_ssl_error(
107 $method);
108 0 ▶ wantarray ? @rv : $rv[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
109 105 };
110 5 };
111 }
112 14 ▶ if ( my $table = delete $ready{$caller} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $table = delete $ready{$caller}) 10 4 14
113 10 ▶ while ( my ( $method, $code ) = each %$table ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$table) 150 10 160
114 150 ▶ next if $exclude{$method};
Branch: 1 branch
BranchTrueFalseTotal
if $exclude{$method} 0 150 150
115 150 my $fullname = $caller . "::" . $method;
116 150 ▶ next if defined &{$fullname};
Branch: 1 branch
BranchTrueFalseTotal
if defined &{$fullname;} 5 145 150
117 145 *{$fullname} = $install->( $code, $method );
118 }
119 10 ▶ while ( my ( $source, $dest ) = each %include ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %include) 0 10 10
120 0 my $fullname = $caller . "::" . $dest;
121 0 my $code = Net::SSLeay->can($source);
122 0 ▶ next unless $code;
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 0 0
123 0 *{$fullname} = $install->( $code, $dest );
124 }
125 }
126 }
127  
128 5 1;
129  
130 __END__
« OO/Error.pm ↑ Summary OO/X509/Name.pm »