]> gitweb.factorcode.org Git - factor.git/blob - core/io/streams/string/string-tests.factor
ogg plays but 1) sound is broken and 2) it doesn't recognize EOF anymore, so it hangs...
[factor.git] / core / io / streams / string / string-tests.factor
1 USING: io.streams.string io kernel arrays namespaces tools.test ;
2 IN: io.streams.string.tests
3
4 [ "line 1" CHAR: l ]
5 [
6     "line 1\nline 2\nline 3" <string-reader>
7     dup stream-readln swap stream-read1
8 ]
9 unit-test
10
11 [ f ]
12 [ "" <string-reader> stream-readln ]
13 unit-test
14
15 [ "xyzzy" ] [ [ "xyzzy" write ] with-string-writer ] unit-test
16
17 [ "a" ] [ 1 SBUF" cba" stream-read ] unit-test
18 [ "ab" ] [ 2 SBUF" cba" stream-read ] unit-test
19 [ "abc" ] [ 3 SBUF" cba" stream-read ] unit-test
20 [ "abc" ] [ 4 SBUF" cba" stream-read ] unit-test
21 [ "abc" f ] [
22     3 SBUF" cba" [ stream-read ] keep stream-read1
23 ] unit-test
24
25 [
26     {
27         { "It seems " CHAR: J }
28         { "obs has lost h" CHAR: i }
29         { "s grasp on reality again.\n" f }
30     }
31 ] [
32     [
33         "It seems Jobs has lost his grasp on reality again.\n"
34         <string-reader> [
35             "J" read-until 2array ,
36             "i" read-until 2array ,
37             "X" read-until 2array ,
38         ] with-input-stream
39     ] { } make
40 ] unit-test
41
42 [ "hello" "hi" ] [
43     "hello\nhi" <string-reader>
44     dup stream-readln
45     2 rot stream-read
46 ] unit-test
47
48 [ "hello" "hi" ] [
49     "hello\r\nhi" <string-reader>
50     dup stream-readln
51     2 rot stream-read
52 ] unit-test
53
54 [ "hello" "hi" ] [
55     "hello\rhi" <string-reader>
56     dup stream-readln
57     2 rot stream-read
58 ] unit-test