| 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
| |||||||||||||
| 33 | 25 | ▶ | return ref($val) || '(NONREF)'; | ||||||||||
|
Condition100%2/2
ref $val || '(NONREF)'
MC/DC100%1/1
ref $val || '(NONREF)'
ref $val
Truth table100%2/2
A
A= ref $val
| |||||||||||||
| 34 | } | ||||||||||||
| 35 | else { | ||||||||||||
| 36 | 10 | ▶ | return defined($val) ? $val : '(undef)'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 44 | 25 | return uc($1); | |||||||||||
| 45 | } | ||||||||||||
| 46 | else { | ||||||||||||
| 47 | 10 | return sprintf '(%s)' => $self->_expectation; | |||||||||||
| 48 | } | ||||||||||||
| 49 | } | ||||||||||||
| 50 | |||||||||||||
| 51 | 12 | 1; | |||||||||||
| 52 | |||||||||||||
| 53 | __END__ | ||||||||||||