rewrite home page redirect
[dh-make-perl] / dev / arm / libtest-simple-perl / libtest-simple-perl-0.80 / t / is_deeply_dne_bug.t
1 #!/usr/bin/perl -w
2
3 # test for rt.cpan.org 20768
4 #
5 # There was a bug where the internal "does not exist" object could get
6 # confused with an overloaded object.
7
8 BEGIN {
9     if( $ENV{PERL_CORE} ) {
10         chdir 't';
11         @INC = ('../lib', 'lib');
12     }
13     else {
14         unshift @INC, 't/lib';
15     }
16 }
17
18 use strict;
19 use Test::More;
20
21 BEGIN {
22     if( !eval "require overload" ) {
23         plan skip_all => "needs overload.pm";
24     }
25     else {
26         plan tests => 2;
27     }
28 }
29
30 {
31     package Foo;
32
33     use overload
34     'eq' => \&overload_equiv,
35     '==' => \&overload_equiv;
36
37     sub new {
38         return bless {}, shift;
39     }
40
41     sub overload_equiv {
42         if (ref($_[0]) ne 'Foo' || ref($_[1]) ne 'Foo') {
43             print ref($_[0]), " ", ref($_[1]), "\n";
44             die "Invalid object passed to overload_equiv\n";
45         }
46
47         return 1; # change to 0 ... makes little difference
48     }
49 }
50
51 my $obj1 = Foo->new();
52 my $obj2 = Foo->new();
53
54 eval { is_deeply([$obj1, $obj2], [$obj1, $obj2]); };
55 is $@, '';
56