Data-Alias
view release on metacpan or search on metacpan
t/25_alias_weakref.t view on Meta::CPAN
use Test::More tests => 4;
use Data::Alias;
SKIP: {
skip "Scalar::Util not installed", 4
unless eval "use Scalar::Util qw/ weaken /; 42";
my $x = {};
my $y = {};
my $keepalive = $x;
weaken($x);
alias $x->{foo} = $y->{foo};
$x->{foo} = 42;
undef $keepalive;
is $x, undef;
is $y->{foo}, 42;
$x = [];
$keepalive = $x;
weaken($x);
alias push @$x, $y;
$y = 42;
is "@$keepalive", 42;
undef $keepalive;
is $x, undef;
}
# vim: ft=perl
( run in 1.742 second using v1.01-cache-2.11-cpan-39bf76dae61 )