X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F80-leaks.t;h=7b2a3f0ed51d44ec3ddd9d6a693104cb907a1b8e;hb=ae89b589d2187cf0ed57bbb6132b9d4a8da29abb;hp=dcaf66a3d17727c72bb11f1e49aab93978dfcdba;hpb=068ea108c28a60581d00b44976dc979860832c8e;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/80-leaks.t b/t/80-leaks.t index dcaf66a..7b2a3f0 100644 --- a/t/80-leaks.t +++ b/t/80-leaks.t @@ -3,9 +3,9 @@ use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 11; -use Variable::Magic qw/wizard cast/; +use Variable::Magic qw; our $destroyed; @@ -38,3 +38,54 @@ sub D () { 'Variable::Magic::TestDestructor' } is $destroyed, 1; } + +{ + local $destroyed = 0; + + my $w = wizard data => sub { $_[1] }; + + { + my $copy; + + { + my $obj = D->new; + + { + my $x = 1; + cast $x, $w, $obj; + is $destroyed, 0; + $copy = getdata $x, $w; + } + + is $destroyed, 0; + } + + is $destroyed, 0; + } + + is $destroyed, 1; +} + +{ + local $destroyed = 0; + + { + my $obj = D->new; + + { + my $w = wizard set => $obj; + + { + my $x = 1; + cast $x, $w; + is $destroyed, 0; + } + + is $destroyed, 0; + } + + is $destroyed, 0; + } + + is $destroyed, 1; +}