|
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 | |
|---|
| 1 | use strict; |
|---|
| 2 | use warnings; |
|---|
| 3 | |
|---|
| 4 | package Test::Deep::Shallow; |
|---|
| 5 | |
|---|
| 6 | use Test::Deep::Cmp; |
|---|
| 7 | |
|---|
| 8 | use Scalar::Util qw( refaddr ); |
|---|
| 9 | |
|---|
| 10 | sub init |
|---|
| 11 | { |
|---|
| 12 | my $self = shift; |
|---|
| 13 | |
|---|
| 14 | my $val = shift; |
|---|
| 15 | $self->{val} = $val; |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | sub 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 | |
|---|
| 51 | 1; |
|---|