From 083b285f4319c470f307f0b52f03a2fb68facd38 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 26 May 2020 00:17:52 +0200 Subject: =?UTF-8?q?Rename=20=E2=80=9CMinimal=20development=20test=E2=80=9D?= =?UTF-8?q?=20to=20=E2=80=9CDevelopment=20Test=E2=80=9D=20(#9928)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- games/minimal/mods/unittests/player.lua | 73 --------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 games/minimal/mods/unittests/player.lua (limited to 'games/minimal/mods/unittests/player.lua') diff --git a/games/minimal/mods/unittests/player.lua b/games/minimal/mods/unittests/player.lua deleted file mode 100644 index 10781a95f..000000000 --- a/games/minimal/mods/unittests/player.lua +++ /dev/null @@ -1,73 +0,0 @@ --- --- HP Change Reasons --- -local expect = nil -local function run_hpchangereason_tests(player) - expect = { type = "set_hp", from = "mod" } - player:set_hp(3) - assert(expect == nil) - - expect = { a = 234, type = "set_hp", from = "mod" } - player:set_hp(7, { a= 234 }) - assert(expect == nil) - - expect = { df = 3458973454, type = "fall", from = "mod" } - player:set_hp(10, { type = "fall", df = 3458973454 }) - assert(expect == nil) - - player:set_hp(20) -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)) - - 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)) - - meta:set_string("foo", "") - assert(not meta:contains("foo")) - assert(meta:get("foo") == nil) - assert(meta:get_string("foo") == "") - assert(meta:equals(meta2)) -end - -function unittests.test_player(player) - minetest.register_on_player_hpchange(function(player, hp, reason) - if not expect then - return - end - - for key, value in pairs(reason) do - assert(expect[key] == value) - end - - for key, value in pairs(expect) do - assert(reason[key] == value) - end - - expect = nil - end) - - run_hpchangereason_tests(player) - run_player_meta_tests(player) - local msg = "Player tests passed for player '"..player:get_player_name().."'!" - minetest.chat_send_all(msg) - minetest.log("action", "[unittests] "..msg) - return true -end - -- cgit v1.2.3