X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F14-callbacks.t;h=6a1f56f1e0cc35704a06123ff1843d44a01ae5e0;hb=HEAD;hp=ce87f51fec8e2cc99400b4f842a4bf7d303666bf;hpb=7e4218a22df9d95cb7ee69e807675ec8752caa1e;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/14-callbacks.t b/t/14-callbacks.t index ce87f51..6a1f56f 100644 --- a/t/14-callbacks.t +++ b/t/14-callbacks.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 22; +use Test::More tests => 26; use Variable::Magic qw; @@ -65,6 +65,21 @@ is($x, $n, 'callback returning undef fails'); is($x, $n, 'short string callback returns the right thing'); } +{ + my $wiz = eval { wizard get => \undef }; + is($@, '', 'wizard with a ref-to-undef callback doesn\'t croak'); + my $b = $n; + my $res = eval { cast $b, $wiz }; + is($@, '', 'cast a wizard with a ref-to-undef callback doesn\'t croak'); + my $x; + eval { + local $SIG{__WARN__} = sub { die }; + $x = $b; + }; + is($@, '', 'ref-to-undef callback doesn\'t warn/croak'); + is($x, $n, 'ref-to-undef callback returns the right thing'); +} + my @callers; $wiz = wizard get => sub { my @c;