To-do tests for method/isa/overload updates and overloading
authorFather Chrysostomos <sprout@cpan.org>
Fri, 18 May 2012 03:44:48 +0000 (20:44 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 22 May 2012 01:09:24 +0000 (18:09 -0700)
Changes to methods, @ISA, or overload settings should affect objects
that are already blessed into the class.

Currently, objects that existed before any overload settings were in
place do not do overloading at all (bug #112708).  Objects that were
blessed when overload settings were in place are not affected by
changes to methods or @ISA until another object is blessed into the
same class.

lib/overload.t

index c0478ee..54eb75c 100644 (file)
@@ -48,7 +48,7 @@ package main;
 
 $| = 1;
 BEGIN { require './test.pl' }
-plan tests => 5041;
+plan tests => 5045;
 
 use Scalar::Util qw(tainted);
 
@@ -2200,6 +2200,25 @@ fresh_perl_is
       'Error message when sub stub is encountered';
 }
 
+sub eleventative::cos { 'eleven' }
+sub twelvetative::abs { 'twelve' }
+sub thirteentative::abs { 'thirteen' }
+@eleventative::ISA = twelvetative::;
+{
+    local our $TODO = '[perl #112708]';
+    my $o = bless [], 'eleventative';
+    eval 'package eleventative; use overload map +($_)x2, cos=>abs=>';
+    is cos $o, 'eleven', 'overloading applies to object blessed before';
+    bless [], 'eleventative';
+    is cos $o, 'eleven',
+      'ovrld applies to previously-blessed obj after other obj is blessed';
+    $o = bless [], 'eleventative';
+    *eleventative::cos = sub { 'ten' };
+    is cos $o, 'ten', 'method changes affect overloading';
+    @eleventative::ISA = thirteentative::;
+    is abs $o, 'thirteen', 'isa changes affect overloading';
+}
+
 { # undefining the overload stash -- KEEP THIS TEST LAST
     package ant;
     use overload '+' => 'onion';