From 54f6ba105424d583f3ad66ad05790975c5d7a86d Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 17 May 2012 20:44:48 -0700 Subject: [PATCH] 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. --- lib/overload.t | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/overload.t b/lib/overload.t index c0478ee..54eb75c 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'; -- 2.7.4