io.streams.throwing: implement read-until
parent
9a2dd6a96c
commit
90b962bbd3
|
@ -40,6 +40,16 @@ IN: io.streams.throwing.tests
|
|||
[ 1 seek-absolute seek-input 4 read drop ] throws-on-eof
|
||||
] [ stream-exhausted? ] must-fail-with
|
||||
|
||||
[ "asd" CHAR: f ] [
|
||||
"asdf" <string-reader>
|
||||
[ "f" read-until ] throws-on-eof
|
||||
] unit-test
|
||||
|
||||
[
|
||||
"asdf" <string-reader>
|
||||
[ "g" read-until ] throws-on-eof
|
||||
] [ stream-exhausted? ] must-fail-with
|
||||
|
||||
[ 1 ] [
|
||||
"asdf" <string-reader> 2 <limited-stream>
|
||||
[ 1 seek-absolute seek-input tell-input ] throws-on-eof
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2010 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors destructors io kernel locals namespaces
|
||||
sequences ;
|
||||
sequences fry ;
|
||||
IN: io.streams.throwing
|
||||
|
||||
ERROR: stream-exhausted n stream word ;
|
||||
|
@ -34,6 +34,10 @@ M: throws-on-eof stream-tell
|
|||
M: throws-on-eof stream-seek
|
||||
stream>> stream-seek ;
|
||||
|
||||
M: throws-on-eof stream-read-until
|
||||
[ stream>> stream-read-until ]
|
||||
[ '[ length _ \ read-until stream-exhausted ] unless* ] bi ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
: throws-on-eof ( stream quot -- )
|
||||
|
|
Loading…
Reference in New Issue