-
-
Save anonymous/60bc9f5e09b344b1b7ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/t/mojo/ioloop.t b/t/mojo/ioloop.t | |
index 58a1f76..df4013d 100644 | |
--- a/t/mojo/ioloop.t | |
+++ b/t/mojo/ioloop.t | |
@@ -198,6 +198,36 @@ $id = Mojo::IOLoop->client( | |
$delay->wait; | |
is $removed, 1, 'connection has been removed'; | |
+# Interrupted writes | |
+$buffer = ''; | |
+$delay = Mojo::IOLoop->delay; | |
+$end = $delay->begin; | |
+$id = Mojo::IOLoop->server( | |
+(address => '127.0.0.1') => sub { | |
+ my ($loop, $stream) = @_; | |
+ $stream->on(close => $end); | |
+ $stream->on(read => sub { $buffer .= pop }); | |
+ my $cb; | |
+ $cb = sub { shift->write('ping' => $cb) }; | |
+ $stream->$cb; | |
+} | |
+); | |
+$port = Mojo::IOLoop->acceptor($id)->port; | |
+$end2 = $delay->begin; | |
+$id = Mojo::IOLoop->client( | |
+(port => $port) => sub { | |
+ my ($loop, $err, $stream) = @_; | |
+ $stream->once( | |
+ read => sub { | |
+ shift->write('pong' => sub { shift->close }); | |
+ } | |
+ ); | |
+ $stream->on(close => $end2); | |
+} | |
+); | |
+$delay->wait; | |
+is $buffer, 'pong', 'right result'; | |
+ | |
# Stream throttling | |
my ($client, $server, $client_after, $server_before, $server_after); | |
$id = Mojo::IOLoop->server( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment