aboutsummaryrefslogtreecommitdiff
path: root/games/devtest/mods
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2022-07-04 01:06:42 +0200
committerGitHub <noreply@github.com>2022-07-04 01:06:42 +0200
commitfc3460470aec8d73317d2b35edf195bfeec2852c (patch)
treeacfee4e29064b04726bb65b1e0cf026c82834e28 /games/devtest/mods
parent34f15259fa5546dc9abaf974ca5385c276443697 (diff)
downloadminetest-fc3460470aec8d73317d2b35edf195bfeec2852c.tar.gz
minetest-fc3460470aec8d73317d2b35edf195bfeec2852c.tar.bz2
minetest-fc3460470aec8d73317d2b35edf195bfeec2852c.zip
Add missing item alias metatables to async environment (#12458)
Diffstat (limited to 'games/devtest/mods')
-rw-r--r--games/devtest/mods/unittests/async_env.lua10
-rw-r--r--games/devtest/mods/unittests/init.lua1
-rw-r--r--games/devtest/mods/unittests/inside_async_env.lua14
-rw-r--r--games/devtest/mods/unittests/misc.lua2
4 files changed, 19 insertions, 8 deletions
diff --git a/games/devtest/mods/unittests/async_env.lua b/games/devtest/mods/unittests/async_env.lua
index 3a21bd9e2..b7edf941e 100644
--- a/games/devtest/mods/unittests/async_env.lua
+++ b/games/devtest/mods/unittests/async_env.lua
@@ -123,10 +123,10 @@ local function test_handle_async(cb)
core.handle_async(func, function(...)
if not deepequal(expect, {...}) then
- cb("Values did not equal")
+ return cb("Values did not equal")
end
if core.get_last_run_mod() ~= expect[1] then
- cb("Mod name not tracked correctly")
+ return cb("Mod name not tracked correctly")
end
-- Test passing of nil arguments and return values
@@ -134,7 +134,7 @@ local function test_handle_async(cb)
return a, b
end, function(a, b)
if b ~= 123 then
- cb("Argument went missing")
+ return cb("Argument went missing")
end
cb()
end, nil, 123)
@@ -151,7 +151,7 @@ local function test_userdata_passing2(cb, _, pos)
return vm_:get_node_at(pos_)
end, function(ret)
if not deepequal(expect, ret) then
- cb("Node data mismatch (one-way)")
+ return cb("Node data mismatch (one-way)")
end
-- VManip: test a roundtrip
@@ -159,7 +159,7 @@ local function test_userdata_passing2(cb, _, pos)
return vm_
end, function(vm2)
if not deepequal(expect, vm2:get_node_at(pos)) then
- cb("Node data mismatch (roundtrip)")
+ return cb("Node data mismatch (roundtrip)")
end
cb()
end, vm)
diff --git a/games/devtest/mods/unittests/init.lua b/games/devtest/mods/unittests/init.lua
index 96651a878..0e041be76 100644
--- a/games/devtest/mods/unittests/init.lua
+++ b/games/devtest/mods/unittests/init.lua
@@ -36,6 +36,7 @@ local function await(invoke)
called_early = {...}
else
coroutine.resume(co, ...)
+ co = nil
end
end)
if called_early ~= true then
diff --git a/games/devtest/mods/unittests/inside_async_env.lua b/games/devtest/mods/unittests/inside_async_env.lua
index 9774771f9..4ed0fccd2 100644
--- a/games/devtest/mods/unittests/inside_async_env.lua
+++ b/games/devtest/mods/unittests/inside_async_env.lua
@@ -2,7 +2,7 @@ unittests = {}
core.log("info", "Hello World")
-function unittests.async_test()
+local function do_tests()
assert(core == minetest)
-- stuff that should not be here
assert(not core.get_player_by_name)
@@ -11,5 +11,15 @@ function unittests.async_test()
-- stuff that should be here
assert(ItemStack)
assert(core.registered_items[""])
- return true
+ -- alias handling
+ assert(core.registered_items["unittests:steel_ingot_alias"].name ==
+ "unittests:steel_ingot")
+end
+
+function unittests.async_test()
+ local ok, err = pcall(do_tests)
+ if not ok then
+ core.log("error", err)
+ end
+ return ok
end
diff --git a/games/devtest/mods/unittests/misc.lua b/games/devtest/mods/unittests/misc.lua
index 4b53004b1..9ddb07061 100644
--- a/games/devtest/mods/unittests/misc.lua
+++ b/games/devtest/mods/unittests/misc.lua
@@ -24,7 +24,7 @@ local function test_dynamic_media(cb, player)
to_player = player:get_player_name(),
}, function(name)
if not call_ok then
- cb("impossible condition")
+ return cb("impossible condition")
end
cb()
end)