]> gitweb.factorcode.org Git - factor.git/blob - basis/io/pipes/pipes-tests.factor
Fix permission bits
[factor.git] / basis / io / pipes / pipes-tests.factor
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
6
7 [ "Hello" ] [
8     utf8 <pipe> [
9         "Hello" print flush
10         readln
11     ] with-stream
12 ] unit-test
13
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
21
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
28
29 [
30     utf8 <pipe> [
31         5 seconds over set-timeout
32         stream-readln
33     ] with-disposal
34 ] must-fail
35
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