io.streams.throwing: implement tell and seek

db4
Joe Groff 2010-07-09 14:08:54 -07:00
parent 0bdc1514fd
commit 99db070c9e
2 changed files with 17 additions and 1 deletions
basis/io/streams/throwing

View File

@ -1,7 +1,7 @@
! Copyright (C) 2010 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: io io.streams.limited io.streams.string
io.streams.throwing tools.test ;
io.streams.throwing tools.test kernel ;
IN: io.streams.throwing.tests
[ "as" ]
@ -34,3 +34,13 @@ IN: io.streams.throwing.tests
"asdf" <string-reader> 2 <limited-stream>
[ contents contents ] throws-on-eof
] [ stream-exhausted? ] must-fail-with
[
"asdf" <string-reader> 2 <limited-stream>
[ 1 seek-absolute seek-input 4 read drop ] 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
] unit-test

View File

@ -28,6 +28,12 @@ M:: throws-on-eof stream-read-partial ( n stream -- seq )
n stream stream>> stream-read-partial
[ n stream \ read-partial stream-exhausted ] unless* ;
M: throws-on-eof stream-tell
stream>> stream-tell ;
M: throws-on-eof stream-seek
stream>> stream-seek ;
PRIVATE>
: throws-on-eof ( stream quot -- )