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