X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F24-free.t;h=eaa7db3ee4da7db5241424aec0cf9fa5edff23c4;hb=HEAD;hp=56fd6931f9636b34057a20728745b7af01a817f4;hpb=77a84f75f33e3ee44e61182dec76699e23025375;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/24-free.t b/t/24-free.t index 56fd693..eaa7db3 100644 --- a/t/24-free.t +++ b/t/24-free.t @@ -1,23 +1,26 @@ #!perl -T -use Test::More tests => 4; +use strict; +use warnings; -use Variable::Magic qw/wizard cast/; +use Test::More tests => 2 * 5 + 1; -my $c = 0; -my $wiz = wizard free => sub { ++$c }; -ok($c == 0, 'free : create wizard'); +use Variable::Magic qw; + +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; - ok($c == 0, 'free : cast'); -} -ok($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; -ok($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 };