1
0
mirror of https://github.com/minetest/minetest.git synced 2025-07-01 07:30:23 +02:00

Get rid of node metadata when it becomes empty

fixes #8943
This commit is contained in:
sfan5
2022-05-26 15:45:34 +02:00
parent 261a8db9dd
commit 8908a91016
3 changed files with 32 additions and 7 deletions

View File

@ -48,3 +48,23 @@ local function test_v3s16_metatable(player, pos)
assert(vector.check(found_pos))
end
unittests.register("test_v3s16_metatable", test_v3s16_metatable, {map=true})
local function test_clear_meta(_, pos)
local ref = core.get_meta(pos)
for way = 1, 3 do
ref:set_string("foo", "bar")
assert(ref:contains("foo"))
if way == 1 then
ref:from_table({})
elseif way == 2 then
ref:from_table(nil)
else
ref:set_string("foo", "")
end
assert(#core.find_nodes_with_meta(pos, pos) == 0, "clearing failed " .. way)
end
end
unittests.register("test_clear_meta", test_clear_meta, {map=true})