package require ten
package require json::write
+if {[array names ::env PERL5LIB]==""} {
+ array set ::env [list PERL5LIB t/lib]
+} else {
+ array set ::env [list PERL5LIB "t/lib:$::env(PERL5LIB)"]
+}
+
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 retain
+set my_host [exec hostname]
-$f1 await_ready
+is [$f1 await_get] $my_host "hostname returned ok via get"
-set my_host [exec hostname]
+is $ready_args $my_host "hostname returned ok via on_ready"
-is [$f1 get] $my_host "hostname retuend ok via get"
+set ortestdata [[$conn send call {*}[jws class_call_handler 0 call ORTestClass new]] await_get]
-$f1 free
+set ortestoid [lindex $ortestdata 0 1]
-is $ready_args $my_host "hostname returned ok via on_ready"
+set ortest [$conn remote_object $ortestoid]
+
+cmp_ok != [pid] [$ortest call pid] "pid is different on the other side"
+
+is [$ortest call counter] 0 "Counter at 0"
+
+is [$ortest call increment] 1 "Incrememt to 1"
+
+is [$ortest call counter] 1 "Counter at 1"
+
+$ortest destroy
+
+done_testing