From 0cd8e61f24ed5d074682961aa5c098a40e75aec4 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 9 May 2008 16:38:27 -0500 Subject: [PATCH] Streams fixes --- core/io/streams/string/string.factor | 5 +---- extra/delegate/protocols/protocols.factor | 5 +++-- extra/io/streams/duplex/duplex-tests.factor | 8 +++++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/core/io/streams/string/string.factor b/core/io/streams/string/string.factor index d43599776b..bcad667c60 100755 --- a/core/io/streams/string/string.factor +++ b/core/io/streams/string/string.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: io kernel math namespaces sequences sbufs strings generic splitting growable continuations io.streams.plain -io.encodings io.encodings.private math.order ; +io.encodings math.order ; IN: io.streams.string M: growable dispose drop ; @@ -77,6 +77,3 @@ M: plain-writer stream-write-table [ drop format-table [ print ] each ] with-output-stream* ; M: plain-writer make-cell-stream 2drop ; - -M: growable stream-readln ( stream -- str ) - "\r\n" over stream-read-until handle-readln ; diff --git a/extra/delegate/protocols/protocols.factor b/extra/delegate/protocols/protocols.factor index c1d7e1e4ab..d4d34f0bd0 100755 --- a/extra/delegate/protocols/protocols.factor +++ b/extra/delegate/protocols/protocols.factor @@ -13,11 +13,12 @@ PROTOCOL: assoc-protocol delete-at clear-assoc new-assoc assoc-like ; PROTOCOL: input-stream-protocol - stream-read1 stream-read stream-read-until stream-read-quot ; + stream-read1 stream-read stream-read-partial stream-readln + stream-read-until stream-read-quot ; PROTOCOL: output-stream-protocol stream-flush stream-write1 stream-write stream-format - stream-nl make-span-stream make-block-stream stream-readln + stream-nl make-span-stream make-block-stream make-cell-stream stream-write-table ; PROTOCOL: definition-protocol diff --git a/extra/io/streams/duplex/duplex-tests.factor b/extra/io/streams/duplex/duplex-tests.factor index ebc6b3be1f..9377256c0d 100755 --- a/extra/io/streams/duplex/duplex-tests.factor +++ b/extra/io/streams/duplex/duplex-tests.factor @@ -1,4 +1,5 @@ -USING: io.streams.duplex io kernel continuations tools.test ; +USING: io.streams.duplex io io.streams.string +kernel continuations tools.test ; IN: io.streams.duplex.tests ! Test duplex stream close behavior @@ -38,3 +39,8 @@ M: unclosable-stream dispose [ dup dispose ] [ 2drop ] recover ] keep closing-stream-closed? ] unit-test + +[ "Hey" ] [ + "Hey\nThere" + stream-readln +] unit-test