Skip to content

Commit 81b4858

Browse files
committed
Add tests for args processing
1 parent 06be5f4 commit 81b4858

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

t/01_run.t

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,4 +540,24 @@ process';
540540
'setting MOJO_PROCESS_DEBUG to 1 enables debug mode when executing external process';
541541
};
542542

543+
subtest 'process_args' => sub {
544+
use Mojo::IOLoop::ReadWriteProcess;
545+
my $code = sub {
546+
shift;
547+
print $_.$/ for(@_);
548+
};
549+
550+
my $p = Mojo::IOLoop::ReadWriteProcess->new($code, args => '0' )->start->wait_stop();
551+
is($p->read_all_stdout(), "0$/", '1) False scalar value was given as args.');
552+
553+
$p = Mojo::IOLoop::ReadWriteProcess->new($code)->args('0')->start->wait_stop();
554+
is($p->read_all_stdout(), "0$/", '2) False scalar value was given as args.');
555+
556+
$p = Mojo::IOLoop::ReadWriteProcess->new($code, args => [(0..3)] )->start->wait_stop();
557+
is($p->read_all_stdout(), "0$/1$/2$/3$/", '1) Args given as arrayref.');
558+
559+
$p = Mojo::IOLoop::ReadWriteProcess->new($code)->args([(0..3)])->start->wait_stop();
560+
is($p->read_all_stdout(), "0$/1$/2$/3$/", '2) Args given as arrayref.');
561+
};
562+
543563
done_testing;

0 commit comments

Comments
 (0)