diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-03-15 17:57:14 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-03-15 17:57:14 +0000 |
commit | 2372186ae65ad0411bfab65604891fae243522b7 (patch) | |
tree | b399d26b6904c9eb509773c7f81ba26cfe983331 /lib/overload.t | |
parent | 41e2f52e2c98325f9d16f0944409e49306c8037b (diff) | |
download | perl-2372186ae65ad0411bfab65604891fae243522b7.tar.gz |
Test for reblessing objects with weak references.
p4raw-id: //depot/perl@27508
Diffstat (limited to 'lib/overload.t')
-rw-r--r-- | lib/overload.t | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/overload.t b/lib/overload.t index cf553ceb86..b12cf27623 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -47,7 +47,7 @@ sub numify { 0 + "${$_[0]}" } # Not needed, additional overhead package main; $| = 1; -use Test::More tests=>503; +use Test::More tests => 509; $a = new Oscalar "087"; @@ -1225,3 +1225,32 @@ foreach my $op (qw(<=> == != < <= > >=)) { ok(!$b, "Expect overloaded boolean"); ok(!$a, "Expect overloaded boolean"); } +{ + use Scalar::Util 'weaken'; + + package Shklitza; + use overload '""' => sub {"CLiK KLAK"}; + + package Ksshfwoom; + use overload '""' => sub {"OOOKK AWK"}; + + package main; + + my ($obj, $ref); + $obj = bless do {my $a; \$a}, 'Shklitza'; + $ref = $obj; + + is ($obj, "CLiK KLAK"); + is ($ref, "CLiK KLAK"); + + weaken $ref; + is ($ref, "CLiK KLAK"); + + bless $obj, 'Ksshfwoom'; + + is ($obj, "OOOKK AWK"); + is ($ref, "OOOKK AWK"); + + undef $obj; + is ($ref, undef); +} |