Commit | Line | Data |
3c6a0ce7 |
1 | BEGIN { exec(tclsh => 't/tcl/harness.tcl' => $0) } |
2 | |
3 | package require ten |
4 | |
c96546b1 |
5 | set tfh [open {|t/bin/echo.pl} r+] |
3c6a0ce7 |
6 | |
7 | fconfigure $tfh -buffering line |
8 | |
9 | set rch [ten::read_channel %AUTO% -fh $tfh] |
10 | |
11 | proc line_cb {line} { |
12 | global got_line |
13 | set got_line $line |
14 | } |
15 | |
16 | puts $tfh foo |
17 | |
18 | $rch configure -on_line_call line_cb |
19 | |
20 | global got_line |
21 | |
22 | vwait got_line |
23 | |
24 | is $got_line foo "Got line from read channel (send before set cb)" |
25 | |
26 | puts $tfh bar |
27 | |
28 | vwait got_line |
29 | |
30 | is $got_line bar "Got line from read channel (send after set cb)" |
31 | |
c96546b1 |
32 | $rch configure -on_close_call {global got_line; set got_line bye} |
4bac2150 |
33 | |
c96546b1 |
34 | puts $tfh DIE |
3c6a0ce7 |
35 | |
c96546b1 |
36 | vwait got_line |
37 | |
38 | is $got_line bye "Close handler called" |
4bac2150 |
39 | |
40 | done_testing |