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