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 8BEGIN { 9 if( $ENV{PERL_CORE} ) { 10 chdir 't'; 11 @INC = ('../lib', 'lib'); 12 } 13 else { 14 unshift @INC, 't/lib'; 15 } 16} 17 18use strict; 19use Test::More tests => 2; 20 21{ 22 package Foo; 23 24 use overload 25 'eq' => \&overload_equiv, 26 '==' => \&overload_equiv; 27 28 sub new { 29 return bless {}, shift; 30 } 31 32 sub overload_equiv { 33 if (ref($_[0]) ne 'Foo' || ref($_[1]) ne 'Foo') { 34 print ref($_[0]), " ", ref($_[1]), "\n"; 35 die "Invalid object passed to overload_equiv\n"; 36 } 37 38 return 1; # change to 0 ... makes little difference 39 } 40} 41 42my $obj1 = Foo->new(); 43my $obj2 = Foo->new(); 44 45eval { is_deeply([$obj1, $obj2], [$obj1, $obj2]); }; 46is $@, ''; 47 48