288d3f3cce450aab8b956db86a99bda7c9726c39
[scpubgit/TenDotTcl.git] / t / readch.t
1 BEGIN { exec(tclsh => 't/tcl/harness.tcl' => $0) }
2
3 package require ten
4
5 set tfh [open {|./echo.pl} r+]
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
32 done_testing
33