Fix duplex streams

db4
Slava Pestov 2008-05-20 07:55:42 -05:00
parent 6df45b864b
commit e69755ce72
2 changed files with 24 additions and 2 deletions

View File

@ -1,6 +1,7 @@
IN: io.sockets.tests
USING: io.sockets sequences math tools.test namespaces accessors
kernel destructors calendar io.timeouts ;
kernel destructors calendar io.timeouts io.encodings.utf8 io
concurrency.promises threads io.streams.string ;
[ B{ 1 2 3 4 } ]
[ "1.2.3.4" T{ inet4 } inet-pton ] unit-test
@ -68,3 +69,24 @@ kernel destructors calendar io.timeouts ;
[ ] [ 1 seconds "datagram3" get set-timeout ] unit-test
[ "datagram3" get receive ] must-fail
! See what happens if other end is closed
[ ] [ <promise> "port" set ] unit-test
[ ] [
[
"127.0.0.1" 0 <inet4> utf8 <server>
dup addr>> "port" get fulfill
[
accept drop
dup stream-readln drop
"hello" <string-reader> swap stream-copy
] with-disposal
] "Socket close test" spawn drop
] unit-test
[ "hello" f ] [
"port" get ?promise utf8 [
"hi\n" write flush readln readln
] with-client
] unit-test

View File

@ -24,8 +24,8 @@ M: duplex-stream dispose
#! are attached to the same file descriptor, the output
#! buffer needs to be flushed before we close the fd.
[
[ out>> &dispose drop ]
[ in>> &dispose drop ]
[ out>> &dispose drop ]
bi
] with-destructors ;