io.styles refactoring introduced a load error in io.streams.null; fix that, add docs, and remove unused with-null-stream
parent
c47f8feaab
commit
1f29e128c1
|
@ -0,0 +1,28 @@
|
|||
USING: io help.markup help.syntax quotations ;
|
||||
IN: io.streams.null
|
||||
|
||||
HELP: null-reader
|
||||
{ $class-description "Singleton class of null reader streams." } ;
|
||||
|
||||
HELP: null-writer
|
||||
{ $class-description "Singleton class of null writer streams." } ;
|
||||
|
||||
HELP: with-null-reader
|
||||
{ $values { "quot" quotation } }
|
||||
{ $description "Calls the quotation with " { $link input-stream } " rebound to a " { $link null-reader } " which always produces EOF." } ;
|
||||
|
||||
HELP: with-null-writer
|
||||
{ $values { "quot" quotation } }
|
||||
{ $description "Calls the quotation with " { $link output-stream } " rebound to a " { $link null-writer } " which ignores all output." } ;
|
||||
|
||||
ARTICLE: "io.streams.null" "Null streams"
|
||||
"The " { $vocab-link "io.streams.null" } " vocabulary implements a pair of streams which are useful for testing. The null reader always yields EOF and the null writer ignores all output. Conceptually, they are similar to " { $snippet "/dev/null" } " on a Unix system."
|
||||
$nl
|
||||
"Null readers:"
|
||||
{ $subsection null-reader }
|
||||
{ $subsection with-null-writer }
|
||||
"Null writers:"
|
||||
{ $subsection null-writer }
|
||||
{ $subsection with-null-reader } ;
|
||||
|
||||
ABOUT: "io.streams.null"
|
|
@ -1,22 +1,19 @@
|
|||
! Copyright (C) 2007 Slava Pestov.
|
||||
! Copyright (C) 2007, 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel io io.timeouts io.styles destructors ;
|
||||
IN: io.streams.null
|
||||
USING: kernel io io.timeouts io.streams.duplex destructors ;
|
||||
|
||||
TUPLE: null-stream ;
|
||||
SINGLETONS: null-reader null-writer ;
|
||||
UNION: null-stream null-reader null-writer ;
|
||||
|
||||
M: null-stream dispose drop ;
|
||||
M: null-stream set-timeout 2drop ;
|
||||
|
||||
TUPLE: null-reader < null-stream ;
|
||||
|
||||
M: null-reader stream-readln drop f ;
|
||||
M: null-reader stream-read1 drop f ;
|
||||
M: null-reader stream-read-until 2drop f f ;
|
||||
M: null-reader stream-read 2drop f ;
|
||||
|
||||
TUPLE: null-writer < null-stream ;
|
||||
|
||||
M: null-writer stream-write1 2drop ;
|
||||
M: null-writer stream-write 2drop ;
|
||||
M: null-writer stream-nl drop ;
|
||||
|
@ -28,11 +25,7 @@ M: null-writer make-cell-stream nip ;
|
|||
M: null-writer stream-write-table 3drop ;
|
||||
|
||||
: with-null-reader ( quot -- )
|
||||
T{ null-reader } swap with-input-stream* ; inline
|
||||
null-reader swap with-input-stream* ; inline
|
||||
|
||||
: with-null-writer ( quot -- )
|
||||
T{ null-writer } swap with-output-stream* ; inline
|
||||
|
||||
: with-null-stream ( quot -- )
|
||||
T{ duplex-stream f T{ null-reader } T{ null-writer } }
|
||||
swap with-stream* ; inline
|
||||
null-writer swap with-output-stream* ; inline
|
|
@ -0,0 +1,8 @@
|
|||
IN: io.styles.tests
|
||||
USING: io.styles tools.test ;
|
||||
|
||||
\ stream-format must-infer
|
||||
\ stream-write-table must-infer
|
||||
\ make-span-stream must-infer
|
||||
\ make-block-stream must-infer
|
||||
\ make-cell-stream must-infer
|
|
@ -416,12 +416,7 @@ DEFER: bar
|
|||
\ stream-write must-infer
|
||||
\ stream-write1 must-infer
|
||||
\ stream-nl must-infer
|
||||
\ stream-format must-infer
|
||||
\ stream-write-table must-infer
|
||||
\ stream-flush must-infer
|
||||
\ make-span-stream must-infer
|
||||
\ make-block-stream must-infer
|
||||
\ make-cell-stream must-infer
|
||||
|
||||
! Test stream utilities
|
||||
\ lines must-infer
|
||||
|
|
|
@ -108,7 +108,7 @@ unit-test
|
|||
] times
|
||||
.
|
||||
] times
|
||||
] with-null-stream
|
||||
] with-null-writer
|
||||
] unit-test
|
||||
|
||||
[ t ] [
|
||||
|
|
Loading…
Reference in New Issue