From 0b5b32b026291d5bd8e47acebca10259a379fc1c Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 30 Apr 2018 17:42:51 +0100 Subject: MetaDataRef: Add contains() and get() (#7214) --- games/minimal/mods/test/init.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'games/minimal/mods') 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) -- cgit v1.2.3