factor/core/test/io/io.factor

91 lines
2.1 KiB
Factor
Raw Permalink Normal View History

IN: temporary
USING: io kernel math parser strings test ;
2006-09-29 23:03:27 -04:00
[ 4 ] [
2006-11-28 21:57:29 -05:00
"resource:/core/test/io/no-trailing-eol.factor" run-file
2006-09-29 23:03:27 -04:00
] unit-test
: <resource-reader> ( resource -- stream )
resource-path <file-reader> ;
: lines-test ( stream -- line1 line2 )
[ readln readln ] with-stream ;
[
"This is a line."
"This is another line."
] [
2006-11-28 21:57:29 -05:00
"/core/test/io/windows-eol.txt" <resource-reader> lines-test
] unit-test
[
"This is a line."
"This is another line."
] [
2006-11-28 21:57:29 -05:00
"/core/test/io/mac-os-eol.txt" <resource-reader> lines-test
] unit-test
[
"This is a line."
"This is another line."
] [
2006-11-28 21:57:29 -05:00
"/core/test/io/unix-eol.txt" <resource-reader> lines-test
] unit-test
[
"This is a line.\rThis is another line.\r"
] [
2006-11-28 21:57:29 -05:00
"/core/test/io/mac-os-eol.txt" <resource-reader>
2005-02-14 22:15:02 -05:00
[ 500 read ] with-stream
] unit-test
[
255
] [
2006-11-28 21:57:29 -05:00
"/core/test/io/binary.txt" <resource-reader>
[ read1 ] with-stream >fixnum
] unit-test
2004-11-13 18:07:18 -05:00
! Make sure we use correct to_c_string form when writing
[ ] [ "\0" write ] unit-test
[ "" ] [ 0 read ] unit-test
2005-05-04 01:14:45 -04:00
2005-12-24 18:29:31 -05:00
! [ ] [ "123" write 9000 CHAR: x <string> write flush ] unit-test
[ "line 1" CHAR: l ]
[
"line 1\nline 2\nline 3" <string-reader>
dup stream-readln swap stream-read1
]
unit-test
[ f ]
[ "" <string-reader> stream-readln ]
unit-test
[ ] [ 10000 f set-timeout ] unit-test
2006-08-18 00:03:45 -04:00
[ "" ] [
2006-11-28 21:57:29 -05:00
"/core/test/io/binary.txt" <resource-reader>
2006-08-18 00:03:45 -04:00
[ 0.2 read ] with-stream
] unit-test
2006-12-15 16:10:20 -05:00
[ { } ]
[ "/core/test/io/empty-file.txt" <resource-reader> lines ]
unit-test
[ "xyzzy" ] [ [ "xyzzy" write ] string-out ] unit-test
[ { "" } ] [ "" string-lines ] unit-test
[ { "" "" } ] [ "\n" string-lines ] unit-test
[ { "" "" } ] [ "\r" string-lines ] unit-test
[ { "" "" } ] [ "\r\n" string-lines ] unit-test
[ { "hello" } ] [ "hello" string-lines ] unit-test
[ { "hello" "" } ] [ "hello\n" string-lines ] unit-test
[ { "hello" "" } ] [ "hello\r" string-lines ] unit-test
[ { "hello" "" } ] [ "hello\r\n" string-lines ] unit-test
[ { "hello" "hi" } ] [ "hello\nhi" string-lines ] unit-test
[ { "hello" "hi" } ] [ "hello\rhi" string-lines ] unit-test
[ { "hello" "hi" } ] [ "hello\r\nhi" string-lines ] unit-test