File: is_deeply_dne_bug.t

package info (click to toggle)
perl 5.20.2-3%2Bdeb8u11
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 102,964 kB
  • sloc: perl: 555,553; ansic: 214,041; sh: 38,121; pascal: 8,783; cpp: 3,895; makefile: 2,393; xml: 2,325; yacc: 1,741
file content (47 lines) | stat: -rw-r--r-- 887 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl -w

# test for rt.cpan.org 20768
#
# There was a bug where the internal "does not exist" object could get
# confused with an overloaded object.

BEGIN {
    if( $ENV{PERL_CORE} ) {
        chdir 't';
        @INC = ('../lib', 'lib');
    }
    else {
        unshift @INC, 't/lib';
    }
}

use strict;
use Test::More tests => 2;

{
    package Foo;

    use overload
    'eq' => \&overload_equiv,
    '==' => \&overload_equiv;

    sub new {
        return bless {}, shift;
    }

    sub overload_equiv {
        if (ref($_[0]) ne 'Foo' || ref($_[1]) ne 'Foo') {
            print ref($_[0]), " ", ref($_[1]), "\n";
            die "Invalid object passed to overload_equiv\n";
        }

        return 1; # change to 0 ... makes little difference
    }
}

my $obj1 = Foo->new();
my $obj2 = Foo->new();

eval { is_deeply([$obj1, $obj2], [$obj1, $obj2]); };
is $@, '';