--- /dev/null
+BEGIN { exec(tclsh => 't/tcl/harness.tcl' => $0) }
+
+pass "This is a passing test"
+
+done_testing
--- /dev/null
+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
+
--- /dev/null
+lappend ::auto_path snit ten
+package require ten::test
+namespace import ten::test::*
+proc BEGIN {meh} {}
+source [lindex $argv 0]
--- /dev/null
+exec('tclsh','t/tcl/harness.tcl',$0);
--- /dev/null
+package ifneeded ten 0.0.1 [list source [file join $dir ten.tcl]]
+package ifneeded ten::test 0.0.1 [list source [file join $dir test.tcl]]
--- /dev/null
+package require Tcl 8.4
+
+package require snit
+
+namespace eval ::ten:: {
+ set library [file dirname [info script]]
+}
+
+snit::type ten::connector::perl {
+
+ method connect {} {
+ set conn_fh [open {|object-remote-node} r+]
+ set firstline [gets conn_fh]
+ switch $firstline {
+ Shere {}
+ default { error "Expected Shere, got $firstline" }
+ }
+
+ set channel [ten::read_channel %AUTO% -fh $conn_fh]
+
+ set conn [
+ ten::connection %AUTO% -send_to_fh $conn_fh -read_channel $channel
+ ]
+
+ return $conn
+ }
+}
+
+snit::type ten::read_channel {
+ option -fh
+ option -on_close_call
+ option -on_line_call
+
+ constructor {args} {
+ $self configurelist $args
+ fconfigure $options(-fh) -blocking 0
+ fileevent $options(-fh) readable [mymethod ReceiveData]
+ }
+
+ method ReceiveData {} {
+ set chan $options(-fh)
+ if [eof $chan] {
+ if [llength $options(-on_close_call)] {
+ eval $options(-on_close_call)
+ }
+ } else {
+ if [llength $options(-on_line_call)] {
+ while {[llength [set line [gets $chan]]] > 0} {
+ eval [concat $options(-on_line_call) $line]
+ }
+ }
+ }
+ }
+}
+
+package provide ten 0.0.01
--- /dev/null
+namespace eval ::ten::test:: {
+
+ variable test_count 0
+
+ proc pass {reason} {
+ variable test_count
+ incr test_count
+ puts stdout "ok $test_count $reason"
+ }
+
+ proc fail {reason} {
+ variable test_count
+ incr test_count
+ puts stdout "not ok $test_count $reason"
+ }
+
+ proc is {left right reason} {
+ switch $left \
+ $right { pass $reason } \
+ default { fail "$reason: expected $left, got $right" }
+ }
+
+ proc done_testing {} {
+ variable test_count
+ puts stdout "1..$test_count"
+ }
+
+ namespace export pass fail is done_testing
+}
+
+package provide ten::test 0.0.1