6 use Test::More tests => 16;
8 use Variable::Magic qw/wizard cast dispell getdata getsig/;
14 wizard data => sub { $_[0] },
18 ok(!$@, "wizard creation error ($@)");
19 ok(defined $wiz, 'wizard is defined');
20 ok(ref $wiz eq 'SCALAR', 'wizard is a scalar ref');
22 my $res = eval { cast $wiz, $wiz };
23 ok(!$@, "cast on self croaks ($@)");
24 ok($res, 'cast on self invalid');
27 ok($c == 1, 'magic works correctly on self');
29 $res = eval { dispell $wiz, $wiz };
30 ok(!$@, "dispell on self croaks ($@)");
31 ok($res, 'dispell on self invalid');
34 ok($c == 1, 'magic is no longer invoked on self when dispelled');
36 $res = eval { cast $wiz, $wiz, $wiz };
37 ok(!$@, "re-cast on self croaks ($@)");
38 ok($res, 're-cast on self invalid');
40 $w = getdata $wiz, $wiz;
41 ok($c == 1, 'getdata on magical self doesn\'t trigger callbacks');
42 # ok(getsig($w) == getsig($wiz), 'getdata returns the correct wizard');
44 $res = eval { dispell $wiz, $wiz };
45 ok(!$@, "re-dispell on self croaks ($@)");
46 ok($res, 're-dispell on self invalid');
48 $res = eval { cast $wiz, $wiz };
49 ok(!$@, "re-re-cast on self croaks ($@)");
50 ok($res, 're-re-cast on self invalid');
53 # ok($c == 0, 'magic destructor is called');