2005-03-28 23:45:13 -05:00
|
|
|
IN: temporary
|
2005-06-19 18:53:58 -04:00
|
|
|
USING: io kernel math parser strings test ;
|
2004-08-22 21:56:06 -04:00
|
|
|
|
|
|
|
[ 4 ] [ "/library/test/io/no-trailing-eol.factor" run-resource ] unit-test
|
|
|
|
|
|
|
|
: lines-test ( stream -- line1 line2 )
|
2005-07-21 21:43:37 -04:00
|
|
|
[ readln readln ] with-stream ;
|
2004-08-22 21:56:06 -04:00
|
|
|
|
|
|
|
[
|
|
|
|
"This is a line."
|
|
|
|
"This is another line."
|
|
|
|
] [
|
|
|
|
"/library/test/io/windows-eol.txt" <resource-stream> lines-test
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[
|
|
|
|
"This is a line."
|
|
|
|
"This is another line."
|
|
|
|
] [
|
|
|
|
"/library/test/io/mac-os-eol.txt" <resource-stream> lines-test
|
|
|
|
] unit-test
|
2004-08-22 23:02:29 -04:00
|
|
|
|
2005-04-30 00:43:39 -04:00
|
|
|
[
|
|
|
|
"This is a line."
|
|
|
|
"This is another line."
|
|
|
|
] [
|
|
|
|
"/library/test/io/unix-eol.txt" <resource-stream> lines-test
|
|
|
|
] unit-test
|
|
|
|
|
2004-08-22 23:02:29 -04:00
|
|
|
[
|
|
|
|
"This is a line.\rThis is another line.\r"
|
|
|
|
] [
|
2004-09-02 23:00:30 -04:00
|
|
|
"/library/test/io/mac-os-eol.txt" <resource-stream>
|
2005-02-14 22:15:02 -05:00
|
|
|
[ 500 read ] with-stream
|
2004-09-02 23:00:30 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[
|
|
|
|
255
|
|
|
|
] [
|
|
|
|
"/library/test/io/binary.txt" <resource-stream>
|
|
|
|
[ read1 ] with-stream >fixnum
|
2004-08-22 23:02:29 -04:00
|
|
|
] 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
|
2004-12-22 22:16:46 -05:00
|
|
|
|
2005-02-14 22:15:02 -05:00
|
|
|
[ -1 read ] unit-test-fails
|
2005-04-25 03:33:33 -04:00
|
|
|
|
|
|
|
[ "" ] [ 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
|
2005-06-19 18:53:58 -04:00
|
|
|
|
|
|
|
[ "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
|