1 ! Copyright (C) 2010 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: destructors io io.encodings.binary io.encodings.utf8
4 io.files io.streams.byte-array io.streams.string
5 io.streams.throwing kernel namespaces tools.test ;
9 "asdf" [ [ 6 read-partial ] throw-on-eof ] with-string-reader
13 "asdf" [ [ 4 read read1 ] throw-on-eof ] with-string-reader
14 ] [ stream-exhausted? ] must-fail-with
18 "asdf" <string-reader> [
22 ] [ stream-exhausted? ] must-fail-with
25 "asdf" [ [ 5 read ] throw-on-eof ] with-string-reader
26 ] [ stream-exhausted? ] must-fail-with
29 "asdf" [ [ 4 read 4 read ] throw-on-eof ] with-string-reader
30 ] [ stream-exhausted? ] must-fail-with
33 "asdf" [ [ 2 read ] throw-on-eof 3 read ] with-string-reader
37 "vocab:io/streams/throwing/asdf.txt" utf8 [
38 [ 2 read ] throw-on-eof 20 read
42 { B{ 0 1 2 3 } B{ 0 1 2 3 } } [
44 [ 4 read 0 seek-absolute seek-input 4 read ] throw-on-eof
50 [ 1 seek-absolute seek-input 4 read drop ] throw-on-eof
52 ] [ stream-exhausted? ] must-fail-with
55 "asdf" [ [ "f" read-until ] throw-on-eof ] with-string-reader
59 "asdf" [ [ "g" read-until ] throw-on-eof ] with-string-reader
60 ] [ stream-exhausted? ] must-fail-with
64 [ 1 seek-absolute seek-input tell-input ] throw-on-eof
69 B{ 0 1 2 3 } binary [ [
70 input-stream get [ stream-seekable? ] [ stream-length ] bi
71 ] throw-on-eof ] with-byte-reader