]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/24-free.t
This is 0.64
[perl/modules/Variable-Magic.git] / t / 24-free.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 2 * 5 + 1;
7
8 use Variable::Magic qw<cast>;
9
10 use lib 't/lib';
11 use Variable::Magic::TestWatcher;
12
13 my $wiz = init_watcher 'free', 'free';
14
15 my $n = int rand 1000;
16
17 watch {
18  my $a = $n;
19  watch { cast $a, $wiz } { }, 'cast';
20 } { free => 1 }, 'deletion at the end of the scope';
21
22 my $a = $n;
23 watch { cast $a, $wiz } { }, 'cast 2';
24 watch { undef $a } { }, 'explicit deletion with undef()';
25
26 $Variable::Magic::TestWatcher::mg_end = { free => 1 };