mirror of
https://github.com/minetest/minetest.git
synced 2024-11-26 17:43:45 +01:00
Add unit test and feature flag for override_item
This commit is contained in:
parent
b21a974342
commit
5009259473
@ -41,6 +41,7 @@ core.features = {
|
||||
item_meta_range = true,
|
||||
node_interaction_actor = true,
|
||||
moveresult_new_pos = true,
|
||||
override_item_remove_fields = true,
|
||||
}
|
||||
|
||||
function core.has_feature(arg)
|
||||
|
@ -5444,6 +5444,8 @@ Utilities
|
||||
node_interaction_actor = true,
|
||||
-- "new_pos" field in entity moveresult (5.9.0)
|
||||
moveresult_new_pos = true,
|
||||
-- Allow removing definition fields in `minetest.override_item`
|
||||
override_item_remove_fields = true,
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -254,3 +254,15 @@ local function test_gennotify_api()
|
||||
assert(#custom == 0, "custom ids not empty")
|
||||
end
|
||||
unittests.register("test_gennotify_api", test_gennotify_api)
|
||||
|
||||
unittests.register("test_item_registration", function()
|
||||
local itemname = "unittests:test_override_item"
|
||||
minetest.register_item(itemname, {description = "foo"})
|
||||
assert(assert(minetest.registered_items[itemname]).description == "foo")
|
||||
minetest.override_item(itemname, {description = "bar"})
|
||||
assert(assert(minetest.registered_items[itemname]).description == "bar")
|
||||
minetest.override_item(itemname, {}, {"description"})
|
||||
assert(assert(minetest.registered_items[itemname]).description == nil)
|
||||
minetest.unregister_item("unittests:test_override_item")
|
||||
assert(minetest.registered_items["unittests:test_override_item"] == nil)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user