initial harness code and read channel
[scpubgit/TenDotTcl.git] / t / readch.t
diff --git a/t/readch.t b/t/readch.t
new file mode 100644 (file)
index 0000000..288d3f3
--- /dev/null
@@ -0,0 +1,33 @@
+BEGIN { exec(tclsh => 't/tcl/harness.tcl' => $0) }
+
+package require ten
+
+set tfh [open {|./echo.pl} r+]
+
+fconfigure $tfh -buffering line
+
+set rch [ten::read_channel %AUTO% -fh $tfh]
+
+proc line_cb {line} {
+  global got_line
+  set got_line $line
+}
+
+puts $tfh foo
+
+$rch configure -on_line_call line_cb
+
+global got_line
+
+vwait got_line
+
+is $got_line foo "Got line from read channel (send before set cb)"
+
+puts $tfh bar
+
+vwait got_line
+
+is $got_line bar "Got line from read channel (send after set cb)"
+
+done_testing
+