X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2Flib%2FVariable%2FMagic%2FTestWatcher.pm;h=a8499226e06232d82de7b5ca2d67492b4149e143;hb=18975a85575a68ddb2e0e0a6ee8075dac66a3c73;hp=bcbd67e5987ffa91d6c85268df2a72c19c1b1add;hpb=da422089a9a5dfbf84e72ec3ba867063471ff41c;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/lib/Variable/Magic/TestWatcher.pm b/t/lib/Variable/Magic/TestWatcher.pm index bcbd67e..a849922 100644 --- a/t/lib/Variable/Magic/TestWatcher.pm +++ b/t/lib/Variable/Magic/TestWatcher.pm @@ -5,12 +5,12 @@ use warnings; use Test::More; -use Carp qw/croak/; -use Variable::Magic qw/wizard/; +use Carp qw; +use Variable::Magic qw; -use base qw/Exporter/; +use base qw; -our @EXPORT = qw/init_watcher watch/; +our @EXPORT = qw; sub _types { my $t = shift; @@ -28,6 +28,7 @@ sub init_watcher ($;$) { croak 'can\'t initialize twice' if defined $wiz; my $types = _types shift; $prefix = (defined) ? "$_: " : '' for shift; + local $@; %mg = (); $wiz = eval 'wizard ' . join(', ', map { "$_ => sub { \$mg{$_}++;" . ($_ eq 'len' ? '$_[2]' : '0') . '}' @@ -45,7 +46,10 @@ sub watch (&;$$) { my @ret; local %mg = (); local $Test::Builder::Level = ($Test::Builder::Level || 0) + 1; - if (defined $want and not $want) { # scalar context + local $@; + if (not defined $want) { # void context + eval { $code->() }; + } elsif (not $want) { # scalar context $ret[0] = eval { $code->() }; } else { @ret = eval { $code->() };