Permalink
Browse files

Add a test for overloading

doy++
  • Loading branch information...
1 parent 7f571cc commit 66fcd18c76550ebc138d889fa967614da4f87dc1 @rafl committed Nov 15, 2011
Showing with 31 additions and 0 deletions.
  1. +31 −0 t/overload.t
View
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+use Test::More;
+
+use Package::Anon;
+use Symbol;
+use overload ();
+
+my $stash = Package::Anon->new('Foo');
+
+{
+ my $gv = Symbol::gensym;
+ *$gv = {};
+ $stash->{OVERLOAD} = $gv;
+}
+
+{
+ my $gv = Symbol::gensym;
+ *$gv = \&overload::nil;
+ *$gv = \undef;
+ $stash->{'()'} = $gv;
+}
+
+*{ $stash->{OVERLOAD} }{HASH}->{dummy}++;
+
+$stash->add_method('(""' => sub { "overloaded!" });
+
+my $foo = $stash->bless({});
+is "$foo", "overloaded!";
+
+done_testing;

0 comments on commit 66fcd18

Please sign in to comment.