summaryrefslogtreecommitdiff
path: root/lib/overload.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-05-18 09:56:15 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-05-21 18:09:26 -0700
commit0a2c84ab2027a9fdfab9e35378f8e7a35f5413b7 (patch)
treeaf2f97e2cf665c66860621923e7b576047b6dea8 /lib/overload.t
parent54c554f38309fa055396f28507f661ae9fbdde5e (diff)
downloadperl-0a2c84ab2027a9fdfab9e35378f8e7a35f5413b7.tar.gz
gv.c: Check overload tables when overloading is used
Instead of checking whether overload tables are up to date only during bless, do this check whenever using overloading. This allows changes to methods and @ISA that affect overloading to come into effect immediately, instead of requiring a dummy ‘bless[]’ to reset things. (This does not yet apply to @ISA changes that cause non-overloaded classes to start inheriting overloading.) This fixes a bug brought up in ticket #112708, though the original bug still exists. Some tests had to change, but those tests were checking to make sure that caches could go stale and still be used, which made no sense.
Diffstat (limited to 'lib/overload.t')
-rw-r--r--lib/overload.t22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/overload.t b/lib/overload.t
index 045dc6063e..7ff1214d7e 100644
--- a/lib/overload.t
+++ b/lib/overload.t
@@ -131,7 +131,7 @@ $b++;
is(ref $b, "Oscalar");
is($a, "087");
-is($b, "88");
+is($b, "89");
is(ref $a, "Oscalar");
package Oscalar;
@@ -142,7 +142,7 @@ $b++;
is(ref $b, "Oscalar");
is($a, "087");
-is($b, "90");
+is($b, "91");
is(ref $a, "Oscalar");
$b=$a;
@@ -267,11 +267,12 @@ is("$aI", "xx");
is($aI, "xx");
is("b${aI}c", "_._.b.__.xx._.__.c._");
-# Here we test blessing to a package updates hash
+# Here we test that both "no overloading" and
+# blessing to a package update hash
eval "package Oscalar; no overload '.'";
-is("b${a}", "_.b.__.xx._");
+is("b${a}", "bxx");
$x="1";
bless \$x, Oscalar;
is("b${a}c", "bxxc");
@@ -291,8 +292,8 @@ like($@, qr/no method found/);
eval "package Oscalar; sub comple; use overload '~' => 'comple'";
-$na = eval { ~$a }; # Hash was not updated
-like($@, qr/no method found/);
+$na = eval { ~$a };
+is($@, '');
bless \$x, Oscalar;
@@ -303,8 +304,8 @@ is($na, '_!_xx_!_');
$na = 0;
-$na = eval { ~$aI }; # Hash was not updated
-like($@, qr/no method found/);
+$na = eval { ~$aI };
+like($@, '');
bless \$x, OscalarI;
@@ -316,8 +317,8 @@ is($na, '_!_xx_!_');
eval "package Oscalar; sub rshft; use overload '>>' => 'rshft'";
-$na = eval { $aI >> 1 }; # Hash was not updated
-like($@, qr/no method found/);
+$na = eval { $aI >> 1 };
+is($@, '');
bless \$x, OscalarI;
@@ -2213,7 +2214,6 @@ sub thirteentative::abs { 'thirteen' }
undef $TODO;
is cos $o, 'eleven',
'ovrld applies to previously-blessed obj after other obj is blessed';
- $TODO = '[perl #112708]';
$o = bless [], 'eleventative';
*eleventative::cos = sub { 'ten' };
is cos $o, 'ten', 'method changes affect overloading';