File Coverage

File:local/lib/perl5/Test/Deep/Shallow.pm
Coverage:72.2%

linestmtbrancondsubtimecode
1
2
2
2
6
1
40
use strict;
2
2
2
2
5
2
38
use warnings;
3
4package Test::Deep::Shallow;
5
6
2
2
2
7
1
7
use Test::Deep::Cmp;
7
8
2
2
2
5
2
222
use Scalar::Util qw( refaddr );
9
10sub init
11{
12
44
26
        my $self = shift;
13
14
44
16
        my $val = shift;
15
44
127
        $self->{val} = $val;
16}
17
18sub descend
19{
20
44
23
        my $self = shift;
21
22
44
23
        my $got = shift;
23
44
23
        my $exp = $self->{val};
24
25
44
25
        my $ok;
26
27
44
170
        if (!defined $got and !defined $exp)
28        {
29
22
13
                $ok = 1;
30        }
31        elsif (defined $got xor defined $exp)
32        {
33
0
0
                $ok = 0;
34        }
35        elsif (ref $got and ref $exp)
36        {
37
0
0
                $ok = refaddr($got) == refaddr($exp);
38        }
39        elsif (ref $got xor ref $exp)
40        {
41
0
0
                $ok = 0;
42        }
43        else
44        {
45
22
22
                $ok = $got eq $exp;
46        }
47
48
44
48
        return $ok;
49}
50
511;