6 use Test::More tests => 2 * 10 + 9 + 1;
8 use Variable::Magic qw/cast dispell/;
11 use Variable::Magic::TestWatcher;
14 [ qw/get set len clear free copy dup local fetch store exists delete/ ],
20 check { cast &hlagh, $wiz } { }, 'cast';
21 is $x, 0, 'code: cast didn\'t called code';
23 check { hlagh() } { }, 'call without arguments';
24 is $x, 1, 'code: call without arguments succeeded';
26 check { hlagh(1, 2, 3) } { }, 'call with arguments';
27 is $x, 2, 'code: call with arguments succeeded';
29 check { undef *hlagh } { free => 1 }, 'undef symbol table entry';
30 is $x, 2, 'code: undef symbol table entry didn\'t call code';
33 check { *hlagh = sub { ++$y } } { }, 'redefining sub';
35 check { cast &hlagh, $wiz } { }, 're-cast';
36 is $y, 0, 'code: re-cast didn\'t called code';
38 my ($r) = check { \&hlagh } { }, 'reference';
39 is $y, 0, 'code: reference didn\'t called code';
41 check { $r->() } { }, 'call reference';
42 is $y, 1, 'code: call reference succeeded';
43 is $x, 2, 'code: call reference didn\'t called the previous code';
45 check { dispell &hlagh, $wiz } { }, 'dispell';
46 is $y, 1, 'code: dispell didn\'t called code';