factor/library/test/stream.factor

41 lines
702 B
Factor
Raw Normal View History

IN: scratchpad
USE: namespaces
USE: streams
USE: stdio
USE: test
2004-11-28 21:56:58 -05:00
USE: stack
USE: generic
[ "xyzzy" ] [ [ "xyzzy" write ] with-string ] unit-test
2004-11-28 21:56:58 -05:00
TRAITS: xyzzy-stream
M: xyzzy-stream fwrite-attr ( str style stream -- )
[
drop "<" delegate get fwrite
delegate get fwrite
">" delegate get fwrite
] bind ;M
M: xyzzy-stream fclose ( stream -- )
drop ;M
M: xyzzy-stream fflush ( stream -- )
drop ;M
M: xyzzy-stream fauto-flush ( stream -- )
drop ;M
C: xyzzy-stream ( stream -- stream )
[ delegate set ] extend ;C
[
"<xyzzy>"
] [
[
2004-11-29 23:14:12 -05:00
stdio get <xyzzy-stream> [
"xyzzy" write
2004-11-28 21:56:58 -05:00
] with-stream
] with-string
] unit-test