diff --git a/tests/tests/cleanup.lua b/tests/tests/cleanup.lua index 5142d02bb2e7..cd303165487f 100644 --- a/tests/tests/cleanup.lua +++ b/tests/tests/cleanup.lua @@ -68,6 +68,32 @@ function test.clean_network2() end, "unknown") end +function test.clean_network_listener() + local bc1 = BaseControl:new() + local addr1 = network.get_scene() + bc1:register("clnlin1", 1234) + bc1:finalize() + + local bc2 = BaseControl:new() + local addr2 = network.get_scene() + + local tmp + bc2:listen("clnlin1", bc1.Query.Change, function(new) + test.equal(tmp, new, "value did not propagate") + end) + + network.set_scene(addr1) + tmp = 13 + bc1:set("clnlin1", 13) + + network.set_scene(addr2) + bc2:close() + + network.set_scene(addr1) + -- if the listener wasn't cleaned properly, this will fail + bc1:set("clnlin1", 16) +end + function test.unclean_deregister() local bc = BaseControl:new() local addr = network.get_scene() diff --git a/tests/tests/dirty.lua b/tests/tests/dirty.lua index e5974c9781df..96dd4fb0e2df 100644 --- a/tests/tests/dirty.lua +++ b/tests/tests/dirty.lua @@ -77,6 +77,7 @@ function test.finalize_robust() serialization.serialize({ ty=BaseControl.Message.Register, nouns={"finaln2"}, + verbs={"finalv2", "finalv3"}, }) ) @@ -96,11 +97,14 @@ function test.finalize_robust() BaseControl.Network.default_port, serialization.serialize({ ty=BaseControl.Message.Register, - nouns={"finaln3"}, + nouns={"finaln3", "finaln4"}, }) ) - bc2:finalize{"finaln1", "finaln2", "finaln3"} + bc2:finalize{ + "finaln1", "finaln2", "finaln3", + "finaln4", "finalv2", "finalv3", + } test.is_true(bc2:has_noun("finaln1"), "noun missing") test.is_true(bc2:has_noun("finaln2"), "noun missing") diff --git a/tests/tests/local.lua b/tests/tests/local.lua index 96263ab922d7..343599416ed4 100644 --- a/tests/tests/local.lua +++ b/tests/tests/local.lua @@ -47,6 +47,11 @@ function test.register() test.error_raised(function() bc:register("register3", 12) end, "already registered") + + bc:register("register4", function() end) + test.error_raised(function() + bc:register("register4", function() end) + end, "already registered") end function test.register_batch() @@ -143,13 +148,18 @@ function test.call_verb() end) bc:finalize() - bc:call("call1", 1, 2) + local ret = bc:call("call1", 1, 2) test.equal(3, flag1, "call failed") test.equal(1, flag2, "call failed") + test.equal(true, ret, "call not attempted") - bc:call("call1", 10, 10) + local ret = bc:call("call1", 10, 10) test.equal(20, flag1, "call failed") test.equal(2, flag2, "call failed") + test.equal(true, ret, "call not attempted") + + local ret = bc:call("call2", 1, 2, 3) + test.equal(false, ret, "call erroneously attempted") end function test.has_iter_verbs() diff --git a/tests/tests/network.lua b/tests/tests/network.lua index 7f20f6f9cbae..fa71cc7d7b30 100644 --- a/tests/tests/network.lua +++ b/tests/tests/network.lua @@ -64,6 +64,9 @@ function test.call_sync() test.equal(40, ret, "local sync not correct") test.equal("hello", val, "local sync not multiple") test.equal(2, n, "wrong invokation number") + test.error_raised(function() + bc1:call_sync("sync404", 1, 2, 3) + end, "unknown verb") -- Test remote local bc2 = BaseControl:new() @@ -72,4 +75,7 @@ function test.call_sync() test.equal(40, ret, "local sync not correct") test.equal("hello", val, "local sync not multiple") test.equal(4, n, "wrong invokation number") + test.error_raised(function() + bc2:call_sync("sync404", 1, 2, 3) + end, "unknown verb") end