Object/Test.pm

filter: Statementstmt 87.5% 21 / 24 Branchbran 40.0% 4 / 10 Conditioncond 28.5% 4 / 14 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 5 totaltotal 55.0% 38 / 69 CC 10 SCAR 17.7
CC
10
Cov
60%
_CODELIKE
13.3
_CLASS
6.7
new
3.4
CRAP 5.9
↑ Summary Object.pm »
1 package Test::Object::Test;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.08';
8  
9  
10  
11  
12  
13 #####################################################################
14 # Constructor and Accessors
15  
16 1 ▶sub new {
Subroutine new: called CC=3 SCAR=12.3
Pod undocumented
17 1 my $class = shift;
18 1 my $self = bless { @_ }, $class;
19  
20 # Check params
21 1 ▶ unless ( _CLASS($self->class) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_CLASS($self->class)) 0 1 1
22 0 Carp::croak("Did not provide a valid test class");
23 }
24 1 ▶ unless ( _CODELIKE($self->code) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_CODELIKE($self->code)) 0 1 1
25 0 Carp::croak("Did not provide a valid CODE or callable object");
26 }
27  
28 1 $self;
29 }
30  
31 2 ▶sub class {
Subroutine class: called CC=1 SCAR=0.0
Pod undocumented
32 2 $_[0]->{class};
33 }
34  
35 0 ▶sub tests {
Subroutine tests: not called CC=1 SCAR=6.9
Pod undocumented
36 0 $_[0]->{tests};
37 }
38  
39 2 ▶sub code {
Subroutine code: called CC=1 SCAR=0.0
Pod undocumented
40 2 $_[0]->{code};
41 }
42  
43  
44  
45  
46  
47 #####################################################################
48 # Main Methods
49  
50 1 ▶sub run {
Subroutine run: called CC=1 SCAR=0.0
Pod undocumented
51 1 $_[0]->code->( $_[1] );
52 }
53  
54  
55  
56  
57  
58 #####################################################################
59 # Support Functions
60  
61 # Stolen from Params::Util to avoid adding a dependency needlessly
62  
63 1 ▶sub _CLASS ($) {
Subroutine _CLASS: called CC=4 SCAR=19.1
64 1 ▶ (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s) ? $_[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && !ref($_[0]) && $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s ? : 1 0 1
Condition33%2/6
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
!ll&&!rl&&r
001
defined $_[0] and not ref $_[0]
!ll&&!rl&&r
001
MC/DC0%0/3
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
defined $_[0] not ref $_[0] $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
Truth table25%1/4
A and not(B) and C
A= defined $_[0]B= not ref $_[0]C= $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
ABCresult
0XX0
10X0
1100
1111
65 }
66  
67 1 ▶sub _CODELIKE {
Subroutine _CODELIKE: called CC=5 SCAR=25.9
68 1 ▶ (Scalar::Util::reftype($_[0])||'') eq 'CODE'
Branch: 2 branches
BranchTrueFalseTotal
(builtin::reftype($_[0]) || "") eq "CODE" or builtin::blessed($_[0]) and overload::Method($_[0], "&{}") ? $_[0] : undef 1 0 1
overload::Method($_[0], '&{}') ? : 0 0 0
Condition25%2/8
(builtin::reftype($_[0]) || '') eq 'CODE' || builtin::blessed($_[0]) && (overload::Method($_[0], '&{}') ? $_[0] : undef)
l!l&&r!l&&!r
100
builtin::reftype($_[0]) || ''
l!l
10
builtin::blessed($_[0]) and overload::Method($_[0], "&{}") ? $_[0] : undef
!ll&&!rl&&r
000
MC/DC0%0/3
(builtin::reftype($_[0]) || '') eq 'CODE' || builtin::blessed($_[0]) && (overload::Method($_[0], '&{}') ? $_[0] : undef)
builtin::reftype($_[0]) builtin::blessed($_[0]) overload::Method($_[0], "&{}") ? $_[0] : undef
Truth table25%1/4
A || B and C
A= builtin::reftype($_[0])B= builtin::blessed($_[0])C= overload::Method($_[0], "&{}") ? $_[0] : undef
ABCresult
1XX1
0111
00X0
0100
69 or
70 Scalar::Util::blessed($_[0]) and overload::Method($_[0],'&{}')
71 ? $_[0] : undef;
72 }
73  
74 2 1;
↑ Summary Object.pm »