Merge branch 'master' of git://factorcode.org/git/factor
[factor/jcg.git] / basis / io / pipes / pipes-tests.factor
blob5ece6cfdf397f93b095c3da294f6fa96951ad83e
1 USING: io io.pipes io.streams.string io.encodings.utf8
2 io.streams.duplex io.encodings io.timeouts namespaces
3 continuations tools.test kernel calendar destructors
4 accessors debugger math ;
5 IN: io.pipes.tests
7 [ "Hello" ] [
8     utf8 <pipe> [
9         "Hello" print flush
10         readln
11     ] with-stream
12 ] unit-test
14 [ { } ] [ { } run-pipeline ] unit-test
15 [ { f } ] [ { [ f ] } run-pipeline ] unit-test
16 [ { "Hello" } ] [
17     "Hello" [
18         { [ input-stream [ utf8 <decoder> ] change readln ] } run-pipeline
19     ] with-string-reader
20 ] unit-test
22 [ { f "Hello" } ] [
23     {
24         [ output-stream [ utf8 <encoder> ] change "Hello" print flush f ]
25         [ input-stream [ utf8 <decoder> ] change readln ]
26     } run-pipeline
27 ] unit-test
30     utf8 <pipe> [
31         5 seconds over set-timeout
32         stream-readln
33     ] with-disposal
34 ] must-fail
36 [ ] [
37     1000 [
38         utf8 <pipe> [
39             [ in>> dispose ]
40             [ out>> "hi" over stream-write dispose ]
41             bi
42         ] curry ignore-errors
43     ] times
44 ] unit-test