aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--games/minimal/mods/default/init.lua61
-rw-r--r--games/minimal/mods/test/init.lua49
-rw-r--r--games/minimal/mods/test/mod.conf1
3 files changed, 49 insertions, 62 deletions
diff --git a/games/minimal/mods/default/init.lua b/games/minimal/mods/default/init.lua
index bfd938211..02d195cbc 100644
--- a/games/minimal/mods/default/init.lua
+++ b/games/minimal/mods/default/init.lua
@@ -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
-
diff --git a/games/minimal/mods/test/init.lua b/games/minimal/mods/test/init.lua
index 2692cf425..72ca6e692 100644
--- a/games/minimal/mods/test/init.lua
+++ b/games/minimal/mods/test/init.lua
@@ -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()
diff --git a/games/minimal/mods/test/mod.conf b/games/minimal/mods/test/mod.conf
index 0c9722fc3..ae6387e09 100644
--- a/games/minimal/mods/test/mod.conf
+++ b/games/minimal/mods/test/mod.conf
@@ -1,2 +1,3 @@
name = test
description = Adds unit tests for the engine
+optional_depends = default