|
|
|
@ -75,3 +75,29 @@ function test_call_network()
|
|
|
|
assert_equal(4321, tmp, "call incomplete")
|
|
|
|
assert_equal(4321, tmp, "call incomplete")
|
|
|
|
assert_equal(1, n, "call not correct")
|
|
|
|
assert_equal(1, n, "call not correct")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function test_call_sync()
|
|
|
|
|
|
|
|
local bc1 = BaseControl:new()
|
|
|
|
|
|
|
|
local n = 0
|
|
|
|
|
|
|
|
bc1:register("sync1", function(p1, p2)
|
|
|
|
|
|
|
|
assert_equal(p2, 12)
|
|
|
|
|
|
|
|
n = n + 1
|
|
|
|
|
|
|
|
return p1 + 10, "hello"
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
bc1:finalize()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Test locally
|
|
|
|
|
|
|
|
assert_nil(bc1:call("sync1", 20, 12), "call not nil")
|
|
|
|
|
|
|
|
local ret, val = bc1:call_sync("sync1", 30, 12)
|
|
|
|
|
|
|
|
assert_equal(40, ret, "local sync not correct")
|
|
|
|
|
|
|
|
assert_equal("hello", val, "local sync not multiple")
|
|
|
|
|
|
|
|
assert_equal(2, n, "wrong invokation number")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Test remote
|
|
|
|
|
|
|
|
local bc2 = BaseControl:new()
|
|
|
|
|
|
|
|
assert_nil(bc2:call("sync1", 20, 12), "call not nil")
|
|
|
|
|
|
|
|
local ret, val = bc2:call_sync("sync1", 30, 12)
|
|
|
|
|
|
|
|
assert_equal(40, ret, "local sync not correct")
|
|
|
|
|
|
|
|
assert_equal("hello", val, "local sync not multiple")
|
|
|
|
|
|
|
|
assert_equal(4, n, "wrong invokation number")
|
|
|
|
|
|
|
|
end
|
|
|
|
|