Deep/Methods.pm

filter: Statementstmt 100% 50 / 50 Branchbran 91.6% 11 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 4 totaltotal 93.2% 69 / 74 CC 8 SCAR 10.5
CC
8
Cov
98%
descend
5.0
init
3.0
render_stack
2.0
CRAP 2.9
« Deep/Regexp.pm ↑ Summary Deep/MM.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Test::Deep::Methods 1.205;
5  
6 3 ▶use Test::Deep::Cmp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub init
10 28 ▶{
Subroutine init: called CC=3 SCAR=11.0
Pod undocumented
11 28 my $self = shift;
12  
13 # get them all into [$name,@args] => $value format
14 28 my @methods;
15 28 ▶ while (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 46 28 74
16 {
17 46 my $name = shift;
18 46 my $value = shift;
19 46 ▶ push(@methods,
Branch: 1 branch
BranchTrueFalseTotal
ref $name ? : 8 38 46
20 [
21 ref($name) ? $name : [ $name ],
22 $value
23 ]
24 );
25 }
26 28 $self->{methods} = \@methods;
27 }
28  
29 sub descend
30 27 ▶{
Subroutine descend: called CC=5 SCAR=16.1
Pod undocumented
31 27 my $self = shift;
32 27 my $got = shift;
33  
34 27 my $data = $self->data;
35  
36 27 foreach my $method (@{$self->{methods}})
37 {
38 45 $data->{method} = $method;
39  
40 45 my ($call, $exp_res) = @$method;
41 45 my ($name, @args) = @$call;
42  
43 45 local $@;
44  
45 45 my $got_res;
46 45 ▶ if (! eval { $got_res = $self->call_method($got, $call); 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $got_res = $self->call_method($got, $call); 1 } }) 5 40 45
47 5 ▶ die $@ unless $@ =~ /\ACan't locate object method "\Q$name"/;
Branch: 1 branch
BranchTrueFalseTotal
unless $@ =~ /\ACan't locate object method "\Q$name"\E/ 0 5 5
48 5 $got_res = $Test::Deep::DNE;
49 }
50  
51 45 ▶ next if Test::Deep::descend($got_res, $exp_res);
Branch: 1 branch
BranchTrueFalseTotal
if Test::Deep::descend($got_res, $exp_res) 29 16 45
52  
53 16 return 0;
54 }
55  
56 11 return 1;
57 }
58  
59 sub call_method
60 45 ▶{
Subroutine call_method: called CC=1 SCAR=0.0
Pod undocumented
61 45 my $self = shift;
62 45 my ($got, $call) = @_;
63 45 my ($name, @args) = @$call;
64  
65 45 return $got->$name(@args);
66 }
67  
68 sub render_stack
69 15 ▶{
Subroutine render_stack: called CC=2 SCAR=6.9
Pod undocumented
70 15 my $self = shift;
71 15 my ($var, $data) = @_;
72  
73 15 my $method = $data->{method};
74 15 my ($call, $expect) = @$method;
75 15 my ($name, @args) = @$call;
76  
77 15 ▶ my $args = @args ? "(".join(", ", @args).")" : "";
Branch: 1 branch
BranchTrueFalseTotal
@args ? : 4 11 15
78 15 $var .= "->$name$args";
79  
80 15 return $var;
81 }
82  
83 3 1;
84  
85 __END__
« Deep/Regexp.pm ↑ Summary Deep/MM.pm »