Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test Proc::Async.w and .started
  • Loading branch information
moritz committed Jan 25, 2015
1 parent 0630ae1 commit 8c487c0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion S17-procasync/basic.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 26;
plan 30;

my $pc = $*DISTRO.is-win
?? Proc::Async.new( 'cmd', </c echo Hello World> )
Expand All @@ -19,9 +19,14 @@ my $stderr = "";
$so.act: { $stdout ~= $_.subst("\r", "", :g) };
$se.act: { $stderr ~= $_.subst("\r", "", :g) };

nok $pc.started, 'program not yet started';
nok $pc.w, 'Not opened for writing';

my $pm = $pc.start;
isa_ok $pm, Promise;

ok $pc.started, 'program has been started';

throws_like { $pc.start }, X::Proc::Async::AlreadyStarted;

throws_like { $pc.print("foo") }, X::Proc::Async::OpenForWriting, :method<print>;
Expand All @@ -44,6 +49,8 @@ $pc = $*DISTRO.is-win
?? Proc::Async.new( :w, 'cmd', </c type con> )
!! Proc::Async.new( :w, 'cat', );

ok $pc.w, 'opened for writing';

throws_like { $pc.close-stdin }, X::Proc::Async::MustBeStarted, :method<close-stdin>;
throws_like { $pc.kill }, X::Proc::Async::MustBeStarted, :method<kill>;
throws_like { $pc.say(42) }, X::Proc::Async::MustBeStarted, :method<say>;
Expand Down

0 comments on commit 8c487c0

Please sign in to comment.