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

Revision 2583, 1.3 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::Hash;
5
6use Test::Deep::Ref;
7
8sub init
9{
10        my $self = shift;
11
12        my $val = shift;
13
14        $self->{val} = $val;
15}
16
17sub descend
18{
19        my $self = shift;
20
21        my $got = shift;
22
23        my $exp = $self->{val};
24
25        my $data = $self->data;
26
27        return 0 unless Test::Deep::descend($got, $self->hash_keys($exp));
28
29        return 0 unless $self->test_class($got);
30
31        return Test::Deep::descend($got, $self->hash_elements($exp));
32}
33
34sub hash_elements
35{
36        require Test::Deep::HashElements;
37
38        my $self = shift;
39
40        return Test::Deep::HashElements->new(@_);
41}
42
43sub hash_keys
44{
45        require Test::Deep::HashKeys;
46
47        my $self = shift;
48        my $exp = shift;
49
50        return Test::Deep::HashKeys->new(keys %$exp);
51}
52
53sub reset_arrow
54{
55        return 0;
56}
57
58package Test::Deep::SuperHash;
59
60use base 'Test::Deep::Hash';
61
62sub hash_elements
63{
64        require Test::Deep::HashElements;
65
66        my $self = shift;
67
68        return Test::Deep::SuperHashElements->new(@_);
69}
70
71sub hash_keys
72{
73        require Test::Deep::HashKeys;
74
75        my $self = shift;
76        my $exp = shift;
77
78        return Test::Deep::SuperHashKeys->new(keys %$exp);
79}
80
81package Test::Deep::SubHash;
82
83use base 'Test::Deep::Hash';
84
85sub hash_elements
86{
87        require Test::Deep::HashElements;
88
89        my $self = shift;
90
91        return Test::Deep::SubHashElements->new(@_);
92}
93
94sub hash_keys
95{
96        require Test::Deep::HashKeys;
97
98        my $self = shift;
99        my $exp = shift;
100
101        return Test::Deep::SubHashKeys->new(keys %$exp);
102}
103
1041;
Note: See TracBrowser for help on using the browser.