aboutsummaryrefslogtreecommitdiff
path: root/t/Test/Execute.pm
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-04-16 00:01:34 +0200
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-04-16 00:01:34 +0200
commit01b15204ee6e2c3b583e5a4479f53d2651bb20aa (patch)
tree840cef28073351e8ee09b3d439ca3f46ef81f828 /t/Test/Execute.pm
parentc9fa2a454e12542b42a3798af56d689f3c609cd9 (diff)
downloadsbotools2-01b15204ee6e2c3b583e5a4479f53d2651bb20aa.tar.xz
Add Test::Sbotools module, and fix Test::Execute for it
Diffstat (limited to 't/Test/Execute.pm')
-rwxr-xr-xt/Test/Execute.pm8
1 files changed, 5 insertions, 3 deletions
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} }; }