summaryrefslogtreecommitdiff
path: root/lib/overload.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-05-17 20:44:48 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-05-21 18:09:24 -0700
commit54f6ba105424d583f3ad66ad05790975c5d7a86d (patch)
treeedfb69e094b645b37e3a4678a629e4d8a1541664 /lib/overload.t
parenta02807f8b3a2ace8fe1534b6875e29ce99cd38c8 (diff)
downloadperl-54f6ba105424d583f3ad66ad05790975c5d7a86d.tar.gz
To-do tests for method/isa/overload updates and overloading
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.
Diffstat (limited to 'lib/overload.t')
-rw-r--r--lib/overload.t21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/overload.t b/lib/overload.t
index c0478eef7f..54eb75cb9d 100644
--- a/lib/overload.t
+++ b/lib/overload.t
@@ -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';