From 33958975ad258f50f6abea7983274b43db63b09d Mon Sep 17 00:00:00 2001 From: Andreas Guldstrand Date: Sun, 24 Apr 2016 14:03:18 +0200 Subject: Test::Execute: when checking output with a sub, local()ly set $_ --- t/Test/Execute.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 't/Test/Execute.pm') 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"); } -- cgit v1.2.3