|
Revision 2583, 1.0 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::HashKeys; |
|---|
| 5 | |
|---|
| 6 | use Test::Deep::Ref; |
|---|
| 7 | |
|---|
| 8 | sub init |
|---|
| 9 | { |
|---|
| 10 | my $self = shift; |
|---|
| 11 | |
|---|
| 12 | my %keys; |
|---|
| 13 | @keys{@_} = (); |
|---|
| 14 | $self->{val} = \%keys; |
|---|
| 15 | $self->{keys} = [sort @_]; |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | sub descend |
|---|
| 19 | { |
|---|
| 20 | my $self = shift; |
|---|
| 21 | my $got = shift; |
|---|
| 22 | |
|---|
| 23 | my $exp = $self->{val}; |
|---|
| 24 | |
|---|
| 25 | return 0 unless $self->test_reftype($got, "HASH"); |
|---|
| 26 | |
|---|
| 27 | return Test::Deep::descend($got, $self->hashkeysonly($exp)); |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | sub hashkeysonly |
|---|
| 31 | { |
|---|
| 32 | require Test::Deep::HashKeysOnly; |
|---|
| 33 | |
|---|
| 34 | my $self = shift; |
|---|
| 35 | my $exp = shift; |
|---|
| 36 | |
|---|
| 37 | return Test::Deep::HashKeysOnly->new(keys %$exp) |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | package Test::Deep::SuperHashKeys; |
|---|
| 41 | |
|---|
| 42 | use base 'Test::Deep::HashKeys'; |
|---|
| 43 | |
|---|
| 44 | sub hashkeysonly |
|---|
| 45 | { |
|---|
| 46 | require Test::Deep::HashKeysOnly; |
|---|
| 47 | |
|---|
| 48 | my $self = shift; |
|---|
| 49 | my $exp = shift; |
|---|
| 50 | |
|---|
| 51 | return Test::Deep::SuperHashKeysOnly->new(keys %$exp) |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | package Test::Deep::SubHashKeys; |
|---|
| 55 | |
|---|
| 56 | use base 'Test::Deep::HashKeys'; |
|---|
| 57 | |
|---|
| 58 | sub hashkeysonly |
|---|
| 59 | { |
|---|
| 60 | require Test::Deep::HashKeysOnly; |
|---|
| 61 | |
|---|
| 62 | my $self = shift; |
|---|
| 63 | my $exp = shift; |
|---|
| 64 | |
|---|
| 65 | return Test::Deep::SubHashKeysOnly->new(keys %$exp) |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | 1; |
|---|