]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/10-simple.t
Store a placeholder in the wizards set for every manually generated signature.
[perl/modules/Variable-Magic.git] / t / 10-simple.t
index 0b17fdeccd149fedaa977c0ee087b8965707a742..1617fdc997b152ee97779423b1acbbd4d06e2066 100644 (file)
@@ -3,10 +3,12 @@
 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;
@@ -25,14 +27,18 @@ for (0 .. 3) {
 
 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');
 
@@ -45,12 +51,12 @@ is($@, '', 're-cast doesn\'t croak');
 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');
@@ -68,9 +74,9 @@ $sig = gensig;
 }
 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');