Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add missing awaits to ensure correct test output.
Also, due to improvements in IO::Socket::Async, connection failures
will always be delivered through a broken Promise, rather than maybe
being immediate or maybe breaking the Promise.
  • Loading branch information
jnthn committed Jun 5, 2014
1 parent 17d7071 commit 09c9b75
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions S32-io/IO-Socket-Async.t
Expand Up @@ -7,15 +7,15 @@ my $hostname = 'localhost';
my $port = 5000;

try {
IO::Socket::Async.listen('veryunlikelyhostname.bogus', $port).tap(quit => { say 'quit'});
CATCH {
default {
is $_.payload, 'Failed to resolve host name', 'Async listen on bogus hostname';
}
}
my $sync = Promise.new;
IO::Socket::Async.listen('veryunlikelyhostname.bogus', $port).tap(quit => {
is $_.payload, 'Failed to resolve host name', 'Async listen on bogus hostname';
$sync.keep(1);
});
await $sync;
}

IO::Socket::Async.connect($hostname, $port).then(-> $sr {
await IO::Socket::Async.connect($hostname, $port).then(-> $sr {
is $sr.status, Broken, 'Async connect to unavailable server breaks promise';
});

Expand All @@ -27,7 +27,7 @@ my $echoTap = $server.tap(-> $c {
}, quit => { say $_; });
});

IO::Socket::Async.connect($hostname, $port).then(-> $sr{
await IO::Socket::Async.connect($hostname, $port).then(-> $sr{
is $sr.status, Kept, 'Async connect to available server keeps promise';
$sr.result.close() if $sr.status == Kept;
});
Expand Down

0 comments on commit 09c9b75

Please sign in to comment.