minimal: Move get_craft_result tests to test mod
authorPaul Ouellette <oue.paul18@gmail.com>
Tue, 9 Jul 2019 22:36:28 +0000 (18:36 -0400)
committersfan5 <sfan5@live.de>
Sat, 27 Jul 2019 12:42:41 +0000 (14:42 +0200)
games/minimal/mods/default/init.lua
games/minimal/mods/test/init.lua
games/minimal/mods/test/mod.conf

index bfd938211258d8b7ef23502df1764a11bb6ec8c8..02d195cbc8bd58c02788d636fc9d00ed9509aaa4 100644 (file)
@@ -1835,64 +1835,3 @@ minetest.register_on_dignode(on_dignode)
 function on_punchnode(p, node)
 end
 minetest.register_on_punchnode(on_punchnode)
-
---
--- Test some things
---
-
-local function test_get_craft_result()
-       minetest.log("info", "test_get_craft_result()")
-       -- normal
-       local input = {
-               method = "normal",
-               width = 2,
-               items = {"", "default:coal_lump", "", "default:stick"}
-       }
-       minetest.log("info", "torch crafting input: "..dump(input))
-       local output, decremented_input = minetest.get_craft_result(input)
-       minetest.log("info", "torch crafting output: "..dump(output))
-       minetest.log("info", "torch crafting decremented input: "..dump(decremented_input))
-       assert(output.item)
-       minetest.log("info", "torch crafting output.item:to_table(): "..dump(output.item:to_table()))
-       assert(output.item:get_name() == "default:torch")
-       assert(output.item:get_count() == 4)
-       -- fuel
-       local input = {
-               method = "fuel",
-               width = 1,
-               items = {"default:coal_lump"}
-       }
-       minetest.log("info", "coal fuel input: "..dump(input))
-       local output, decremented_input = minetest.get_craft_result(input)
-       minetest.log("info", "coal fuel output: "..dump(output))
-       minetest.log("info", "coal fuel decremented input: "..dump(decremented_input))
-       assert(output.time)
-       assert(output.time > 0)
-       -- cook
-       local input = {
-               method = "cooking",
-               width = 1,
-               items = {"default:cobble"}
-       }
-       minetest.log("info", "cobble cooking input: "..dump(output))
-       local output, decremented_input = minetest.get_craft_result(input)
-       minetest.log("info", "cobble cooking output: "..dump(output))
-       minetest.log("info", "cobble cooking decremented input: "..dump(decremented_input))
-       assert(output.time)
-       assert(output.time > 0)
-       assert(output.item)
-       minetest.log("info", "cobble cooking output.item:to_table(): "..dump(output.item:to_table()))
-       assert(output.item:get_name() == "default:stone")
-       assert(output.item:get_count() == 1)
-end
-test_get_craft_result()
-
---
--- Done, print some random stuff
---
-
---print("minetest.registered_entities:")
---dump2(minetest.registered_entities)
-
--- END
-
index 2692cf4253ceede1243b1dfb63c633b6a96dca94..72ca6e6923eba4f821799c415a1d413d43be35e4 100644 (file)
@@ -43,7 +43,6 @@ minetest.register_on_player_hpchange(function(player, hp, reason)
 end)
 
 
-
 local function run_player_meta_tests(player)
        local meta = player:get_meta()
        meta:set_string("foo", "bar")
@@ -81,3 +80,51 @@ local function run_player_tests(player)
        minetest.chat_send_all("All tests pass!")
 end
 minetest.register_on_joinplayer(run_player_tests)
+
+
+local function test_get_craft_result()
+       minetest.log("info", "test_get_craft_result()")
+       -- normal
+       local input = {
+               method = "normal",
+               width = 2,
+               items = {"", "default:coal_lump", "", "default:stick"}
+       }
+       minetest.log("info", "torch crafting input: "..dump(input))
+       local output, decremented_input = minetest.get_craft_result(input)
+       minetest.log("info", "torch crafting output: "..dump(output))
+       minetest.log("info", "torch crafting decremented input: "..dump(decremented_input))
+       assert(output.item)
+       minetest.log("info", "torch crafting output.item:to_table(): "..dump(output.item:to_table()))
+       assert(output.item:get_name() == "default:torch")
+       assert(output.item:get_count() == 4)
+       -- fuel
+       local input = {
+               method = "fuel",
+               width = 1,
+               items = {"default:coal_lump"}
+       }
+       minetest.log("info", "coal fuel input: "..dump(input))
+       local output, decremented_input = minetest.get_craft_result(input)
+       minetest.log("info", "coal fuel output: "..dump(output))
+       minetest.log("info", "coal fuel decremented input: "..dump(decremented_input))
+       assert(output.time)
+       assert(output.time > 0)
+       -- cook
+       local input = {
+               method = "cooking",
+               width = 1,
+               items = {"default:cobble"}
+       }
+       minetest.log("info", "cobble cooking input: "..dump(output))
+       local output, decremented_input = minetest.get_craft_result(input)
+       minetest.log("info", "cobble cooking output: "..dump(output))
+       minetest.log("info", "cobble cooking decremented input: "..dump(decremented_input))
+       assert(output.time)
+       assert(output.time > 0)
+       assert(output.item)
+       minetest.log("info", "cobble cooking output.item:to_table(): "..dump(output.item:to_table()))
+       assert(output.item:get_name() == "default:stone")
+       assert(output.item:get_count() == 1)
+end
+test_get_craft_result()
index 0c9722fc33788a5395a8c9cc6ab25d915a7909a4..ae6387e0937e18d17c1e69895b56daea37cce111 100644 (file)
@@ -1,2 +1,3 @@
 name = test
 description = Adds unit tests for the engine
+optional_depends = default