X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F80-leaks.t;fp=t%2F80-leaks.t;h=dcaf66a3d17727c72bb11f1e49aab93978dfcdba;hb=068ea108c28a60581d00b44976dc979860832c8e;hp=0000000000000000000000000000000000000000;hpb=480d76182c123d90242fc84e0ee3d94733f11a99;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/80-leaks.t b/t/80-leaks.t new file mode 100644 index 0000000..dcaf66a --- /dev/null +++ b/t/80-leaks.t @@ -0,0 +1,40 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More tests => 3; + +use Variable::Magic qw/wizard cast/; + +our $destroyed; + +{ + package Variable::Magic::TestDestructor; + + sub new { bless { }, shift } + + sub DESTROY { ++$::destroyed } +} + +sub D () { 'Variable::Magic::TestDestructor' } + +{ + local $destroyed = 0; + + my $w = wizard data => sub { $_[1] }; + + { + my $obj = D->new; + + { + my $x = 1; + cast $x, $w, $obj; + is $destroyed, 0; + } + + is $destroyed, 0; + } + + is $destroyed, 1; +}