root/branches/release-40/t/lib/Test/Deep/Shallow.pm @ 2583

Revision 2583, 0.6 kB (checked in by mpaschal, 18 months ago)

Add Test::Deep to t/lib, since we already use it in driver-tests.pl
BugzID: 79953

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