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