sbotools2

Maintenance fork of the original sbotools version 2
Log | Files | Refs | README

commit 33958975ad258f50f6abea7983274b43db63b09d
parent 572ad45b5959edbc943f64da07cb077e90c69693
Author: Andreas Guldstrand <andreas.guldstrand@gmail.com>
Date:   Sun, 24 Apr 2016 14:03:18 +0200

Test::Execute: when checking output with a sub, local()ly set $_

Diffstat:
Mt/Test/Execute.pm | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/t/Test/Execute.pm b/t/Test/Execute.pm @@ -59,6 +59,7 @@ sub run { if (defined $expected and ref $expected eq 'Regexp') { return $output =~ $expected; } elsif (defined $expected and ref $expected eq 'CODE') { + local $_ = $output; return $expected->($output); } return $return; @@ -82,7 +83,8 @@ sub run { } elsif (ref $expected eq 'Regexp') { like ($output, $expected, "$name - output"); } elsif (ref $expected eq 'CODE') { - ok ($expected->($output), "$name - output"); + local $_ = $output; + ok ($expected->($output), "$name - output") or note "Output: $output"; } else { is ($output, $expected, "$name - output"); }