add await_get and switch code to use it
[scpubgit/TenDotTcl.git] / t / connection.t
index 6ce7931..e0425c9 100644 (file)
@@ -7,16 +7,26 @@ set connector [ten::connector::perl %AUTO%]
 
 set conn [$connector connect]
 
+proc jws {args} {
+  set ret {}
+  foreach str $args {
+    lappend ret [ json::write string $str ]
+  }
+  return $ret
+}
+
 set f1 [
-  $conn send call [ json::write string class_call_handler ] \
-    0 [ json::write string call ] \
-    [ json::write string Sys::Hostname ] [ json::write string hostname ]
+  $conn send call {*}[jws class_call_handler 0 call Sys::Hostname hostname]
 ]
 
 set ready_args ""
 
 $f1 on_ready [list apply {{name future} {set $name [$future get]}} "[namespace current]::ready_args" ]
 
-$f1 await_ready
+set my_host [exec hostname]
+
+is [$f1 await_get] $my_host "hostname returned ok via get"
+
+is $ready_args $my_host "hostname returned ok via on_ready"
 
-is $ready_args [exec hostname] "hostname returned ok"
+done_testing