Graph/Attribute.pm

filter: Statementstmt 100% 96 / 97 (1 uncoverable) Branchbran 87.5% 21 / 24 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 24 / 24 Podpod 0.0% 0 / 10 totaltotal 90.6% 145 / 161 (1 uncoverable) CC 16 SCAR 7.8
CC
16
Cov
97%
import
5.0
__ANON__
3.1
__ANON__
3.0
CRAP 2.2
« Graph/SPTHeapElem.pm ↑ Summary Graph/MSTHeapElem.pm »
1 package Graph::Attribute;
2  
3 86 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 86 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 86 my @API = qw(get_attribute
7 get_attributes
8 set_attribute
9 set_attributes
10 has_attribute
11 has_attributes
12 delete_attribute
13 delete_attributes
14 get_attribute_names
15 get_attribute_values);
16  
17 86 ▶sub import {
Subroutine import: called CC=5 SCAR=16.1
18 86 my $package = shift;
19 86 my %attr = @_;
20 86 my $caller = caller(0);
21 86 ▶ if (exists $attr{array}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $attr{'array'}) { } 85 1 86
elsif (exists $attr{'hash'}) { } 1 0 1
22 85 my $i = $attr{array};
23 86 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 85 ▶ *{"${caller}::_g_get_attributes"} = sub { $_[0]->[ $i ] };
Subroutine __ANON__: called CC=1 SCAR=0.0
25 85 *{"${caller}::_g_set_attributes"} =
26 631 ▶ sub { $_[0]->[ $i ] ||= { };
Subroutine __ANON__: called CC=3 SCAR=11.0
Condition100%2/2
$_[0][$i] ||= {}
l!l
336295
MC/DC100%1/1
$_[0][$i] ||= {}
$_[0][$i]
Truth table100%2/2
A
A= $_[0][$i]
Aresult
11
00
27 631 ▶ $_[0]->[ $i ] = $_[1] if @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 4 627 631
28 85 $_[0]->[ $i ] };
29 85 ▶ *{"${caller}::_g_has_attributes"} = sub { defined $_[0]->[ $i ] };
Subroutine __ANON__: called CC=1 SCAR=0.0
30 85 ▶ *{"${caller}::_g_delete_attributes"} = sub { undef $_[0]->[ $i ]; 1 };
Subroutine __ANON__: called CC=1 SCAR=0.0
31 } elsif (exists $attr{hash}) {
32 1 my $k = $attr{hash};
33 86 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶ *{"${caller}::_g_get_attributes"} = sub { $_[0]->{ $k } };
Subroutine __ANON__: called CC=1 SCAR=0.0
35 1 *{"${caller}::_g_set_attributes"} =
36 1 ▶ sub { $_[0]->{ $k } ||= { };
Subroutine __ANON__: called CC=3 SCAR=11.4
Condition50%1/2
$_[0]{$k} ||= {}
l!l
01
MC/DC0%0/1
$_[0]{$k} ||= {}
$_[0]{$k}
Truth table50%1/2
A
A= $_[0]{$k}
Aresult
11
00
37 1 ▶ $_[0]->{ $k } = $_[1] if @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 1 0 1
38 1 $_[0]->{ $k } };
39 1 ▶ *{"${caller}::_g_has_attributes"} = sub { defined $_[0]->{ $k } };
Subroutine __ANON__: called CC=1 SCAR=0.0
40 1 ▶ *{"${caller}::_g_delete_attributes"} = sub { delete $_[0]->{ $k } };
Subroutine __ANON__: called CC=1 SCAR=0.0
41 } else {
42 # uncoverable statement
43 0 die "Graph::Attribute::import($package @_) caller $caller\n";
44 }
45 86 ▶ if (exists $attr{map}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $attr{"map"}) 84 2 86
46 84 my $map = $attr{map};
47 84 for my $api (@API) {
48 840 my ($first, $rest) = ($api =~ /^(\w+?)_(.+)/);
49 86 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
50 840 *{"${caller}::${first}_${map}_${rest}"} = \&$api;
51 }
52 }
53 }
54  
55 627 ▶sub set_attribute {
Subroutine set_attribute: called CC=1 SCAR=0.0
Pod undocumented
56 627 my $g = shift;
57 627 my $v = pop;
58 627 my $a = pop;
59 627 my $p = $g->_g_set_attributes;
60 627 $p->{ $a } = $v;
61 627 return 1;
62 }
63  
64 3 ▶sub set_attributes {
Subroutine set_attributes: called CC=1 SCAR=0.0
Pod undocumented
65 3 my $g = shift;
66 3 my $a = pop;
67 3 my $p = $g->_g_set_attributes( $a );
68 3 return 1;
69 }
70  
71 3 ▶sub has_attribute {
Subroutine has_attribute: called CC=2 SCAR=7.0
Pod undocumented
72 3 my $g = shift;
73 3 my $a = pop;
74 3 my $p = $g->_g_get_attributes;
75 3 ▶ $p ? exists $p->{ $a } : 0;
Branch: 1 branch
BranchTrueFalseTotal
$p ? : 3 0 3
76 }
77  
78 10 ▶sub has_attributes {
Subroutine has_attributes: called CC=2 SCAR=6.9
Pod undocumented
79 10 my $g = shift;
80 10 ▶ $g->_g_get_attributes ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$g->_g_get_attributes ? : 7 3 10
81 }
82  
83 15724 ▶sub get_attribute {
Subroutine get_attribute: called CC=2 SCAR=6.9
Pod undocumented
84 15724 my $g = shift;
85 15724 my $a = pop;
86 15724 my $p = $g->_g_get_attributes;
87 15724 ▶ $p ? $p->{ $a } : undef;
Branch: 1 branch
BranchTrueFalseTotal
$p ? : 15558 166 15724
88 }
89  
90 230 ▶sub delete_attribute {
Subroutine delete_attribute: called CC=2 SCAR=6.9
Pod undocumented
91 230 my $g = shift;
92 230 my $a = pop;
93 230 ▶ return 0 unless defined(my $p = $g->_g_get_attributes);
Branch: 1 branch
BranchTrueFalseTotal
unless defined(my $p = $g->_g_get_attributes) 1 229 230
94 229 delete $p->{ $a };
95 229 return 1;
96 }
97  
98 2 ▶sub delete_attributes {
Subroutine delete_attributes: called CC=2 SCAR=6.9
Pod undocumented
99 2 my $g = shift;
100 2 ▶ return 0 if !$g->_g_has_attributes;
Branch: 1 branch
BranchTrueFalseTotal
unless $g->_g_has_attributes 1 1 2
101 1 $g->_g_delete_attributes;
102 1 return 1;
103 }
104  
105 3 ▶sub get_attribute_names {
Subroutine get_attribute_names: called CC=2 SCAR=6.9
Pod undocumented
106 3 my $g = shift;
107 3 my $p = $g->_g_get_attributes;
108 3 ▶ defined $p ? keys %{ $p } : ( );
Branch: 1 branch
BranchTrueFalseTotal
defined $p ? : 2 1 3
109 }
110  
111 3 ▶sub get_attribute_values {
Subroutine get_attribute_values: called CC=2 SCAR=6.9
Pod undocumented
112 3 my $g = shift;
113 3 my $p = $g->_g_get_attributes;
114 3 ▶ defined $p ? values %{ $p } : ( );
Branch: 1 branch
BranchTrueFalseTotal
defined $p ? : 2 1 3
115 }
116  
117 6 ▶sub get_attributes {
Subroutine get_attributes: called CC=1 SCAR=0.0
Pod undocumented
118 6 $_[0]->_g_get_attributes;
119 }
120  
121 86 1;
« Graph/SPTHeapElem.pm ↑ Summary Graph/MSTHeapElem.pm »