X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F24-free.t;h=eaa7db3ee4da7db5241424aec0cf9fa5edff23c4;hb=9ad970e109ea4caa9767db1bda9d475444920c7a;hp=89e2c06aab5db85a3813e178f542008f64f5fe13;hpb=a86e3e47a167afadf7de1231d6401a1139330ad0;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/24-free.t b/t/24-free.t index 89e2c06..eaa7db3 100644 --- a/t/24-free.t +++ b/t/24-free.t @@ -3,24 +3,24 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 2 * 5 + 1; -use Variable::Magic qw/wizard cast/; +use Variable::Magic qw; -my $c = 0; -my $wiz = wizard free => sub { ++$c }; -is($c, 0, 'free : create wizard'); +use lib 't/lib'; +use Variable::Magic::TestWatcher; + +my $wiz = init_watcher 'free', 'free'; my $n = int rand 1000; -{ +watch { my $a = $n; - - cast $a, $wiz; - is($c, 0, 'free : cast'); -} -is($c, 1, 'free : deletion at the end of the scope'); + watch { cast $a, $wiz } { }, 'cast'; +} { free => 1 }, 'deletion at the end of the scope'; my $a = $n; -undef $n; -is($c, 1, 'free : explicit deletion with undef()'); +watch { cast $a, $wiz } { }, 'cast 2'; +watch { undef $a } { }, 'explicit deletion with undef()'; + +$Variable::Magic::TestWatcher::mg_end = { free => 1 };