41e0e2cadc8af4a07e2869f166184e2b601ddfea
[scpubgit/TenDotTcl.git] / t / connection.t
1 BEGIN { exec(tclsh => 't/tcl/harness.tcl' => $0) }
2
3 package require ten
4 package require json::write
5
6 set connector [ten::connector::perl %AUTO%]
7
8 set conn [$connector connect]
9
10 proc jws {args} {
11   set ret {}
12   foreach str $args {
13     lappend ret [ json::write string $str ]
14   }
15   return $ret
16 }
17
18 set f1 [
19   $conn send call {*}[jws class_call_handler 0 call Sys::Hostname hostname]
20 ]
21
22 set ready_args ""
23
24 $f1 on_ready [list apply {{name future} {set $name [$future get]}} "[namespace current]::ready_args" ]
25
26 $f1 retain
27
28 $f1 await_ready
29
30 set my_host [exec hostname]
31
32 is [$f1 get] $my_host "hostname retuend ok via get"
33
34 $f1 free
35
36 is $ready_args $my_host "hostname returned ok via on_ready"
37
38 done_testing