1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Fix node callbacks unit test

This commit is contained in:
sfan5 2024-02-24 00:53:22 +01:00
parent 9b97147637
commit 91ea47fddf
3 changed files with 22 additions and 13 deletions

View file

@ -99,17 +99,24 @@ local function test_clear_meta(_, pos)
end
unittests.register("test_clear_meta", test_clear_meta, {map=true})
local on_punch_called
minetest.register_on_punchnode(function()
local on_punch_called, on_place_called
core.register_on_placenode(function()
on_place_called = true
end)
core.register_on_punchnode(function()
on_punch_called = true
end)
unittests.register("test_punch_node", function(_, pos)
minetest.place_node(pos, {name="basenodes:dirt"})
local function test_node_callbacks(_, pos)
on_place_called = false
on_punch_called = false
minetest.punch_node(pos)
minetest.remove_node(pos)
-- currently failing: assert(on_punch_called)
end, {map=true})
core.place_node(pos, {name="basenodes:dirt"})
assert(on_place_called, "on_place not called")
core.punch_node(pos)
assert(on_punch_called, "on_punch not called")
core.remove_node(pos)
end
unittests.register("test_node_callbacks", test_node_callbacks, {map=true})
local function test_hashing()
local input = "hello\000world"