blib/lib/Class/Data/Localize.pm

filter: Statementstmt 96.7% 30 / 31 Branchbran 90.0% 9 / 10 Conditioncond 83.3% 5 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 91.3% 53 / 58 CC 8 SCAR 14.9
CC
8
Cov
94%
__ANON__
7.1
mk_classdata
2.0
BEGIN
1.0
CRAP 4.4
↑ Summary
1 package Class::Data::Localize;
2  
3 4 ▶use strict qw(vars subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 $VERSION = '0.0401';
6  
7 4 ▶use ReleaseAction ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 15 ▶sub mk_classdata {
Subroutine mk_classdata: called CC=2 SCAR=6.9
Pod documented
10 15 my ($declaredclass, $attribute, $data) = @_;
11  
12 15 ▶ if( ref $declaredclass ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $declaredclass) 1 14 15
13 1 require Carp;
14 1 Carp::croak("mk_classdata() is a class method, not an object method");
15 }
16  
17 53 ▶ my $accessor = sub {
Subroutine __ANON__: called CC=7 SCAR=19.6
18 53 ▶ my $wantclass = ref($_[0]) || $_[0];
Condition66%2/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
1520
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table66%2/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
19  
20 53 ▶ if(@_==3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) { } 10 43 53
21 10 my $current = $data;
22 10 ▶ $_[2] = ReleaseAction->new( sub { $data = $current } );
Subroutine __ANON__: called CC=1 SCAR=0.0
23  
24 10 ▶ if($wantclass ne $declaredclass){
Branch: 1 branch
BranchTrueFalseTotal
if ($wantclass ne $declaredclass) 0 10 10
25 0 return mk_classdata($wantclass,$attribute,$data)->(@_);
26 }
27 }
28 else {
29 43 ▶ return mk_classdata($wantclass,$attribute)->(@_)
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 and $wantclass ne $declaredclass 6 37 43
Condition100%3/3
@_ > 1 and $wantclass ne $declaredclass
!ll&&!rl&&r
2896
MC/DC100%2/2
@_ > 1 and $wantclass ne $declaredclass
@_ > 1 $wantclass ne $declaredclass
Truth table100%3/3
A and B
A= @_ > 1B= $wantclass ne $declaredclass
ABresult
0X0
100
111
30 if @_>1 && $wantclass ne $declaredclass;
31 }
32 47 ▶ $data = $_[1] if @_>1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 19 28 47
33 47 return $data;
34 14 };
35  
36 14 my $alias = "_${attribute}_accessor";
37 14 *{$declaredclass.'::'.$attribute} = $accessor;
38 14 *{$declaredclass.'::'.$alias} = $accessor;
39 }
40  
41 4 1;
42  
43 __END__
↑ Summary