|
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 | |
|---|
| 1 | use strict; |
|---|
| 2 | use warnings; |
|---|
| 3 | |
|---|
| 4 | package Test::Deep::Hash; |
|---|
| 5 | |
|---|
| 6 | use Test::Deep::Ref; |
|---|
| 7 | |
|---|
| 8 | sub init |
|---|
| 9 | { |
|---|
| 10 | my $self = shift; |
|---|
| 11 | |
|---|
| 12 | my $val = shift; |
|---|
| 13 | |
|---|
| 14 | $self->{val} = $val; |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | sub 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 | |
|---|
| 34 | sub hash_elements |
|---|
| 35 | { |
|---|
| 36 | require Test::Deep::HashElements; |
|---|
| 37 | |
|---|
| 38 | my $self = shift; |
|---|
| 39 | |
|---|
| 40 | return Test::Deep::HashElements->new(@_); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | sub 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 | |
|---|
| 53 | sub reset_arrow |
|---|
| 54 | { |
|---|
| 55 | return 0; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | package Test::Deep::SuperHash; |
|---|
| 59 | |
|---|
| 60 | use base 'Test::Deep::Hash'; |
|---|
| 61 | |
|---|
| 62 | sub hash_elements |
|---|
| 63 | { |
|---|
| 64 | require Test::Deep::HashElements; |
|---|
| 65 | |
|---|
| 66 | my $self = shift; |
|---|
| 67 | |
|---|
| 68 | return Test::Deep::SuperHashElements->new(@_); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | sub 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 | |
|---|
| 81 | package Test::Deep::SubHash; |
|---|
| 82 | |
|---|
| 83 | use base 'Test::Deep::Hash'; |
|---|
| 84 | |
|---|
| 85 | sub hash_elements |
|---|
| 86 | { |
|---|
| 87 | require Test::Deep::HashElements; |
|---|
| 88 | |
|---|
| 89 | my $self = shift; |
|---|
| 90 | |
|---|
| 91 | return Test::Deep::SubHashElements->new(@_); |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | sub 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 | |
|---|
| 104 | 1; |
|---|