File Coverage

blib/lib/Test/Deep/Shallow.pm
Criterion Covered Total %
statement 26 26 100.0
branch 8 8 100.0
condition 12 14 85.7
subroutine 6 6 100.0
pod 0 2 0.0
total 52 56 92.8


line stmt bran cond sub pod time code
1 30     30   216 use strict;
  30         67  
  30         1242  
2 30     30   202 use warnings;
  30         79  
  30         2432  
3              
4             package Test::Deep::Shallow 1.205;
5              
6 30     30   2174 use Test::Deep::Cmp;
  30         62  
  30         272  
7              
8 30     30   223 use Scalar::Util qw( refaddr );
  30         70  
  30         8804  
9              
10             sub init
11             {
12 831     831 0 1301 my $self = shift;
13              
14 831         1523 my $val = shift;
15 831         3902 $self->{val} = $val;
16             }
17              
18             sub descend
19             {
20 820     820 0 1524 my $self = shift;
21              
22 820         2261 my $got = shift;
23 820         1555 my $exp = $self->{val};
24              
25 820         1324 my $ok;
26              
27 820 100 100     6588 if (!defined $got and !defined $exp)
    100 75        
    100 100        
    100 75        
28             {
29 148         257 $ok = 1;
30             }
31             elsif (defined $got xor defined $exp)
32             {
33 67         139 $ok = 0;
34             }
35             elsif (ref $got and ref $exp)
36             {
37 4         10 $ok = refaddr($got) == refaddr($exp);
38             }
39             elsif (ref $got xor ref $exp)
40             {
41 36         75 $ok = 0;
42             }
43             else
44             {
45 565         1377 $ok = $got eq $exp;
46             }
47              
48 820         2470 return $ok;
49             }
50              
51             1;
52              
53             __END__