X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F80-leaks.t;h=647419f01d6b9ec722984719f7824938a40c7d44;hb=e5e39f5e8bec67b3a08f861da63c5eb4cafed09f;hp=dcaf66a3d17727c72bb11f1e49aab93978dfcdba;hpb=068ea108c28a60581d00b44976dc979860832c8e;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/80-leaks.t b/t/80-leaks.t index dcaf66a..647419f 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/wizard cast getdata/; 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; +}