Add ARM files
[dh-make-perl] / dev / arm / libtest-simple-perl / libtest-simple-perl-0.80 / t / is_deeply_dne_bug.t
diff --git a/dev/arm/libtest-simple-perl/libtest-simple-perl-0.80/t/is_deeply_dne_bug.t b/dev/arm/libtest-simple-perl/libtest-simple-perl-0.80/t/is_deeply_dne_bug.t
new file mode 100644 (file)
index 0000000..56515f9
--- /dev/null
@@ -0,0 +1,56 @@
+#!/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;
+
+BEGIN {
+    if( !eval "require overload" ) {
+        plan skip_all => "needs overload.pm";
+    }
+    else {
+        plan 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 $@, '';
+