summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-04-30 17:42:51 +0100
committerSmallJoker <SmallJoker@users.noreply.github.com>2018-04-30 18:42:51 +0200
commit0b5b32b026291d5bd8e47acebca10259a379fc1c (patch)
tree6e308bb5ccf3fb3050a40cd784456387c67b106e /games
parent54606e103d5b2d2bace6d57c45e48804c5dec487 (diff)
downloadminetest-0b5b32b026291d5bd8e47acebca10259a379fc1c.tar.gz
minetest-0b5b32b026291d5bd8e47acebca10259a379fc1c.tar.bz2
minetest-0b5b32b026291d5bd8e47acebca10259a379fc1c.zip
MetaDataRef: Add contains() and get() (#7214)
Diffstat (limited to 'games')
-rw-r--r--games/minimal/mods/test/init.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/games/minimal/mods/test/init.lua b/games/minimal/mods/test/init.lua
index 9b826bce6..3141b4cf3 100644
--- a/games/minimal/mods/test/init.lua
+++ b/games/minimal/mods/test/init.lua
@@ -43,21 +43,32 @@ end)
local function run_player_meta_tests(player)
local meta = player:get_meta()
meta:set_string("foo", "bar")
+ assert(meta:contains("foo"))
assert(meta:get_string("foo") == "bar")
+ assert(meta:get("foo") == "bar")
local meta2 = player:get_meta()
assert(meta2:get_string("foo") == "bar")
+ assert(meta2:get("foo") == "bar")
assert(meta:equals(meta2))
assert(player:get_attribute("foo") == "bar")
meta:set_string("bob", "dillan")
assert(meta:get_string("foo") == "bar")
assert(meta:get_string("bob") == "dillan")
+ assert(meta:get("bob") == "dillan")
assert(meta2:get_string("foo") == "bar")
assert(meta2:get_string("bob") == "dillan")
+ assert(meta2:get("bob") == "dillan")
assert(meta:equals(meta2))
assert(player:get_attribute("foo") == "bar")
assert(player:get_attribute("bob") == "dillan")
+
+ meta:set_string("foo", "")
+ assert(not meta:contains("foo"))
+ assert(meta:get("foo") == nil)
+ assert(meta:get_string("foo") == "")
+ assert(meta:equals(meta2))
end
local function run_player_tests(player)