X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/41e2f52e2c98325f9d16f0944409e49306c8037b..2372186ae65ad0411bfab65604891fae243522b7:/lib/overload.t diff --git a/lib/overload.t b/lib/overload.t index cf553ce..b12cf27 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); +}