diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-04-24 14:03:18 +0200 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-04-24 14:03:18 +0200 |
commit | 33958975ad258f50f6abea7983274b43db63b09d (patch) | |
tree | a841444751d93b1d84bf928f0025035e537abc4d /t | |
parent | 572ad45b5959edbc943f64da07cb077e90c69693 (diff) | |
download | sbotools2-33958975ad258f50f6abea7983274b43db63b09d.tar.xz |
Test::Execute: when checking output with a sub, local()ly set $_
Diffstat (limited to 't')
-rwxr-xr-x | t/Test/Execute.pm | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/t/Test/Execute.pm b/t/Test/Execute.pm index 0a0acaa..26b576a 100755 --- 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"); } |