--- /dev/null
+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"
\ No newline at end of file
-! 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 ;
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
\ No newline at end of file
--- /dev/null
+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
\ No newline at end of file
\ 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