From 01b15204ee6e2c3b583e5a4479f53d2651bb20aa Mon Sep 17 00:00:00 2001 From: Andreas Guldstrand Date: Sat, 16 Apr 2016 00:01:34 +0200 Subject: Add Test::Sbotools module, and fix Test::Execute for it --- t/Test/Execute.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 't/Test/Execute.pm') diff --git a/t/Test/Execute.pm b/t/Test/Execute.pm index 3ce5178..0a0acaa 100755 --- a/t/Test/Execute.pm +++ b/t/Test/Execute.pm @@ -58,6 +58,8 @@ sub run { if (not $test) { if (defined $expected and ref $expected eq 'Regexp') { return $output =~ $expected; + } elsif (defined $expected and ref $expected eq 'CODE') { + return $expected->($output); } return $return; } @@ -90,14 +92,14 @@ sub run { sub script { my @cmd; - while (exists $_[0] and not defined reftype($_[0])) { + while (@_ and not defined reftype($_[0])) { my $arg = shift @_; push @cmd, $arg; } my %args; - if (reftype($_[0]) eq 'HASH') { %args = %{ $_[0] }; } - else { croak "Unknown argument passed: $_[0]"; } + if (@_ and reftype($_[0]) eq 'HASH') { %args = %{ $_[0] }; } + elsif (@_) { croak "Unknown argument passed: $_[0]"; } if (exists $args{cmd} and @cmd) { croak "More than one command passed"; } if (exists $args{cmd}) { @cmd = @{ $args{cmd} }; } -- cgit v1.2.3