Matcher/DataUtil.pm

filter: Statementstmt 100% 31 / 31 Branchbran 100% 6 / 6 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 5 totaltotal 90.9% 50 / 55 CC 5 SCAR 6.9
CC
5
Cov
100%
renderGot
4.0
renderExp
2.0
BEGIN
1.0
CRAP 2.0
↑ Summary Matcher.pm »
1 package Test::Deep::Matcher::DataUtil;
2  
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use Test::Deep::Cmp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use Data::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 67 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
9 67 my $self = shift;
10 67 my ($name, @args) = @_;
11  
12 67 $self->{name} = $name;
13 67 $self->{matcher} = Data::Util->can($name);
14 67 $self->{val} = \@args;
15 }
16  
17 67 ▶sub descend {
Subroutine descend: called CC=1 SCAR=0.0
Pod undocumented
18 67 my ($self, $got) = @_;
19 67 return $self->{matcher}->($got);
20 }
21  
22 45 ▶sub _expectation { join ' ' => split /_/ => shift->{name} }
Subroutine _expectation: called CC=1 SCAR=0.0
23  
24 35 ▶sub diag_message {
Subroutine diag_message: called CC=1 SCAR=0.0
Pod undocumented
25 35 my ($self, $got) = @_;
26 35 return sprintf 'Checking %s %s' => $got, $self->_expectation;
27 }
28  
29 35 ▶sub renderGot {
Subroutine renderGot: called CC=4 SCAR=13.9
Pod undocumented
30 35 my ($self, $val) = @_;
31  
32 35 ▶ if ($self->{name} =~ /_ref/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'name'} =~ /_ref/) { } 25 10 35
33 25 ▶ return ref($val) || '(NONREF)';
Condition100%2/2
ref $val || '(NONREF)'
l!l
205
MC/DC100%1/1
ref $val || '(NONREF)'
ref $val
Truth table100%2/2
A
A= ref $val
Aresult
11
00
34 }
35 else {
36 10 ▶ return defined($val) ? $val : '(undef)';
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 6 4 10
37 }
38 }
39  
40 35 ▶sub renderExp {
Subroutine renderExp: called CC=2 SCAR=6.9
Pod undocumented
41 35 my ($self, $val) = @_;
42  
43 35 ▶ if ($self->{name} =~ /is_(.+)_ref/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'name'} =~ /is_(.+)_ref/) { } 25 10 35
44 25 return uc($1);
45 }
46 else {
47 10 return sprintf '(%s)' => $self->_expectation;
48 }
49 }
50  
51 12 1;
52  
53 __END__
↑ Summary Matcher.pm »