use strict;
use warnings;
-use Test::More tests => 46;
+use Test::More tests => 48;
use Variable::Magic qw/wizard gensig getsig cast dispell MGf_COPY MGf_DUP MGf_LOCAL VMG_UVAR/;
+my $inv_wiz_obj = qr/Invalid\s+wizard\s+object\s+at\s+\Q$0\E/;
+
my $args = 8;
++$args if MGf_COPY;
++$args if MGf_DUP;
my $sig = gensig;
+my $a = 1;
+my $res = eval { cast $a, $sig };
+like($@, $inv_wiz_obj, 'cast from wrong sig croaks');
+is($res, undef, 'cast from wrong sig doesn\'t return anything');
+
my $wiz = eval { wizard sig => $sig };
is($@, '', 'wizard doesn\'t croak');
ok(defined $wiz, 'wizard is defined');
is(ref $wiz, 'SCALAR', 'wizard is a scalar ref');
is($sig, getsig $wiz, 'wizard signature is correct');
-my $a = 1;
-my $res = eval { cast $a, $wiz };
+$res = eval { cast $a, $wiz };
is($@, '', 'cast doesn\'t croak');
ok($res, 'cast is valid');
ok($res, 're-cast is valid');
$res = eval { dispell $a, gensig };
-like($@, qr/Invalid\s+wizard\s+object\s+at\s+\Q$0\E/, 're-dispell from wrong sig croaks');
-is($res, undef, 're-dispell from wrong sig doesn\'t return anything');
+like($@, $inv_wiz_obj, 're-dispell from wrong sig croaks');
+is($res, undef, 're-dispell from wrong sig doesn\'t return anything');
$res = eval { dispell $a, undef };
-like($@, qr/Invalid\s+wizard\s+object\s+at\s+\Q$0\E/, 're-dispell from undef croaks');
-is($res, undef, 're-dispell from undef doesn\'t return anything');
+like($@, $inv_wiz_obj, 're-dispell from undef croaks');
+is($res, undef, 're-dispell from undef doesn\'t return anything');
$res = eval { dispell $a, $sig };
is($@, '', 're-dispell from good sig doesn\'t croak');
}
my $c = 3;
$res = eval { cast $c, $sig };
-is($@, '', 'cast from obsolete signature doesn\'t croak');
-is($res, undef, 'cast from obsolete signature returns undef');
+like($@, $inv_wiz_obj, 'cast from obsolete signature croaks');
+is($res, undef, 'cast from obsolete signature returns undef');
$res = eval { cast $c, undef };
-like($@, qr/Invalid\s+wizard\s+object\s+at\s+\Q$0\E/, 'cast from undef croaks');
-is($res, undef, 'cast from undef doesn\'t return anything');
+like($@, $inv_wiz_obj, 'cast from undef croaks');
+is($res, undef, 'cast from undef doesn\'t return anything');