blib/lib/DTL/Fast/Expression/Operator/Binary/Plus.pm

filter: Statementstmt 61.1% 22 / 36 Branchbran 27.2% 6 / 22 Conditioncond 22.2% 4 / 18 MC/DCmcdc 20.0% 2 / 10 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 43.0% 40 / 93 SCAR 45.8
CC
20
Cov
42%
dispatch
185.9
BEGIN
1.0
BEGIN
1.0
CRAP 97.6
« blib/lib/DTL/Fast/Utils.pm ↑ Summary blib/lib/DTL/Fast/Expression/Operator/Binary/In.pm »
1 package DTL::Fast::Expression::Operator::Binary::Plus;
2 2 ▶use strict; use utf8; use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use parent 'DTL::Fast::Expression::Operator::Binary';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 $DTL::Fast::OPS_HANDLERS{'+'} = __PACKAGE__;
6  
7 2 ▶use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub dispatch
10 {
11 81 ▶ my( $self, $arg1, $arg2, $context) = @_;
Subroutine dispatch: called CC=20 SCAR=52.3
Pod undocumented
12 81 my ($arg1_type, $arg2_type) = (ref $arg1, ref $arg2);
13  
14 81 ▶ if( looks_like_number($arg1) and looks_like_number($arg2))
Branch: 5 branches
BranchTrueFalseTotal
if (&looks_like_number($arg1) and &looks_like_number($arg2)) { } 75 6 81
elsif ($arg1_type eq 'ARRAY') { } 0 6 6
elsif ($arg1_type eq 'HASH') { } 0 6 6
elsif (UNIVERSAL::can($arg1, 'plus')) { } 0 6 6
elsif (defined $arg1 and defined $arg2) { } 6 0 6
Condition100%3/3
&looks_like_number($arg1) and &looks_like_number($arg2)
!ll&&!rl&&r
5175
MC/DC100%2/2
&looks_like_number($arg1) and &looks_like_number($arg2)
&looks_like_number($arg1) &looks_like_number($arg2)
Truth table100%3/3
A and B
A= &looks_like_number($arg1)B= &looks_like_number($arg2)
ABresult
0X0
100
111
15 {
16 75 return $arg1 + $arg2;
17 }
18 elsif( $arg1_type eq 'ARRAY' )
19 {
20 0 ▶ if( $arg2_type eq 'ARRAY' )
Branch: 3 branches
BranchTrueFalseTotal
if ($arg2_type eq 'ARRAY') { } 0 0 0
elsif ($arg2_type eq 'HASH') { } 0 0 0
elsif (UNIVERSAL::can($arg2, 'as_array')) { } 0 0 0
21 {
22 0 return [@$arg1, @$arg2];
23 }
24 elsif( $arg2_type eq 'HASH' )
25 {
26 0 return [@$arg1, %$arg2];
27 }
28 elsif( UNIVERSAL::can($arg2, 'as_array'))
29 {
30 0 return [@$arg1, @{$arg2->as_array($context)}];
31 }
32 else
33 {
34 0 return [@$arg1, $arg2];
35 }
36 }
37 elsif( $arg1_type eq 'HASH' )
38 {
39 0 ▶ if( $arg2_type eq 'ARRAY' )
Branch: 3 branches
BranchTrueFalseTotal
if ($arg2_type eq 'ARRAY') { } 0 0 0
elsif ($arg2_type eq 'HASH') { } 0 0 0
elsif (UNIVERSAL::can($arg2, 'as_hash')) { } 0 0 0
40 {
41 0 return {%$arg1, @$arg2};
42 }
43 elsif( $arg2_type eq 'HASH' )
44 {
45 0 return {%$arg1, %$arg2};
46 }
47 elsif( UNIVERSAL::can($arg2, 'as_hash'))
48 {
49 0 return {%$arg1, %{$arg2->as_hash($context)}};
50 }
51 else
52 {
53 0 ▶ die $self->get_render_error(
Condition0%0/4
$arg2 // "undef"
l!l
00
$arg2_type || 'SCALAR'
l!l
00
MC/DC0%0/1
$arg2 // "undef"
$arg2
MC/DC0%0/1
$arg2_type || 'SCALAR'
$arg2_type
Truth table0%0/2
A
A= $arg2
Aresult
11
00
Truth table0%0/2
A
A= $arg2_type
Aresult
11
00
54 $context,
55 sprintf("don't know how to add %s (%s) to a HASH"
56 , $arg2 // 'undef'
57 , $arg2_type || 'SCALAR'
58 )
59 );
60 }
61 }
62 elsif( UNIVERSAL::can($arg1, 'plus'))
63 {
64 0 return $arg1->plus($arg2, $context);
65 }
66 ▶ elsif(
Condition33%1/3
defined $arg1 and defined $arg2
!ll&&!rl&&r
006
MC/DC0%0/2
defined $arg1 and defined $arg2
defined $arg1 defined $arg2
Truth table33%1/3
A and B
A= defined $arg1B= defined $arg2
ABresult
0X0
100
111
67 defined $arg1
68 and defined $arg2
69 )
70 {
71 6 return $arg1.$arg2;
72 }
73 else
74 {
75 0 ▶ die $self->get_render_error(
Condition0%0/8
$arg1 // "undef"
l!l
00
$arg1_type || 'SCALAR'
l!l
00
$arg2 // "undef"
l!l
00
$arg2_type || 'SCALAR'
l!l
00
MC/DC0%0/1
$arg1 // "undef"
$arg1
MC/DC0%0/1
$arg1_type || 'SCALAR'
$arg1_type
MC/DC0%0/1
$arg2 // "undef"
$arg2
MC/DC0%0/1
$arg2_type || 'SCALAR'
$arg2_type
Truth table0%0/2
A
A= $arg1
Aresult
11
00
Truth table0%0/2
A
A= $arg1_type
Aresult
11
00
Truth table0%0/2
A
A= $arg2
Aresult
11
00
Truth table0%0/2
A
A= $arg2_type
Aresult
11
00
76 $context,
77 sprintf("don't know how to add %s (%s) to %s (%s)"
78 , $arg1 // 'undef'
79 , $arg1_type || 'SCALAR'
80 , $arg2 // 'undef'
81 , $arg2_type || 'SCALAR'
82 )
83 );
84 }
85 }
86  
87 2 1;
« blib/lib/DTL/Fast/Utils.pm ↑ Summary blib/lib/DTL/Fast/Expression/Operator/Binary/In.pm »