From b039b6a542509186f85ab58385277cbee181803a Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 11 Mar 2014 11:25:53 -0700 Subject: [PATCH] io.streams.string: cleanup tests. --- basis/io/streams/string/string-tests.factor | 65 ++++++++------------- 1 file changed, 24 insertions(+), 41 deletions(-) diff --git a/basis/io/streams/string/string-tests.factor b/basis/io/streams/string/string-tests.factor index fd19e251c6..b202dccd75 100644 --- a/basis/io/streams/string/string-tests.factor +++ b/basis/io/streams/string/string-tests.factor @@ -6,70 +6,53 @@ IN: io.streams.string.tests [ "line 1" CHAR: l ] [ - "line 1\nline 2\nline 3" - dup stream-readln swap stream-read1 + "line 1\nline 2\nline 3" [ readln read1 ] with-string-reader ] unit-test { { "line 1" "line 2" "line 3" } } [ - "line 1\nline 2\nline 3" stream-lines + "line 1\nline 2\nline 3" [ lines ] with-string-reader ] unit-test { { "" "foo" "bar" "baz" } } [ - "\rfoo\r\nbar\rbaz\n" stream-lines + "\rfoo\r\nbar\rbaz\n" [ lines ] with-string-reader ] unit-test -[ f ] -[ "" stream-readln ] -unit-test +[ f ] [ "" [ readln ] with-string-reader ] unit-test [ "xyzzy" ] [ [ "xyzzy" write ] with-string-writer ] unit-test -[ "a" ] [ 1 "abc" stream-read ] unit-test -[ "ab" ] [ 2 "abc" stream-read ] unit-test -[ "abc" ] [ 3 "abc" stream-read ] unit-test -[ "abc" ] [ 4 "abc" stream-read ] unit-test -[ "abc" f ] [ - 3 "abc" [ stream-read ] keep stream-read1 -] unit-test +[ "a" ] [ "abc" [ 1 read ] with-string-reader ] unit-test +[ "ab" ] [ "abc" [ 2 read ] with-string-reader ] unit-test +[ "abc" ] [ "abc" [ 3 read ] with-string-reader ] unit-test +[ "abc" ] [ "abc" [ 4 read ] with-string-reader ] unit-test +[ "abc" f ] [ "abc" [ 3 read read1 ] with-string-reader ] unit-test [ - { - { "It seems " CHAR: J } - { "obs has lost h" CHAR: i } - { "s grasp on reality again.\n" f } - } + { "It seems " CHAR: J } + { "obs has lost h" CHAR: i } + { "s grasp on reality again.\n" f } ] [ - [ - "It seems Jobs has lost his grasp on reality again.\n" - [ - "J" read-until 2array , - "i" read-until 2array , - "X" read-until 2array , - ] with-input-stream - ] { } make + "It seems Jobs has lost his grasp on reality again.\n" [ + "J" read-until 2array + "i" read-until 2array + "X" read-until 2array + ] with-string-reader ] unit-test -{ "" CHAR: \r } [ - "\r\n" [ "\r" read-until ] with-input-stream +{ "" CHAR: \r } [ "\r\n" [ "\r" read-until ] with-string-reader ] unit-test +{ f f } [ "" [ "\r" read-until ] with-string-reader ] unit-test + +[ "hello" "hi" ] [ + "hello\nhi" [ readln 2 read ] with-string-reader ] unit-test [ "hello" "hi" ] [ - "hello\nhi" - dup stream-readln - 2 rot stream-read + "hello\r\nhi" [ readln 2 read ] with-string-reader ] unit-test [ "hello" "hi" ] [ - "hello\r\nhi" - dup stream-readln - 2 rot stream-read -] unit-test - -[ "hello" "hi" ] [ - "hello\rhi" - dup stream-readln - 2 rot stream-read + "hello\rhi" [ readln 2 read ] with-string-reader ] unit-test ! Issue #70 github