simple context test

This commit is contained in:
BuckarooBanzay 2022-03-29 18:11:49 +02:00
parent b0a51f0e25
commit 185aac97be
3 changed files with 32 additions and 2 deletions

View File

@ -1,6 +1,7 @@
globals = {
"mtscad",
"minetest"
"minetest",
"vector" -- for test-env patching
}
read_globals = {
@ -9,7 +10,7 @@ read_globals = {
table = {fields = {"copy", "getn"}},
-- Minetest
"vector", "ItemStack",
"ItemStack",
"dump", "dump2",
"VoxelArea",

29
spec/context_spec.lua Normal file
View File

@ -0,0 +1,29 @@
require("mineunit")
mineunit("core")
sourcefile("init")
-- patch test env
function vector.zero()
return vector.new(0, 0, 0)
end
function vector.copy(v)
return vector.new(v.x, v.y, v.z)
end
describe("mtscad.create_context() test", function()
it("set_node() works", function()
local origin = { x=4, y=0, z=0 }
local ctx = mtscad.create_context({ pos = origin })
ctx
:with("default:mese")
:set_node()
local node = minetest.get_node(origin)
assert.not_nil(node)
assert.equal("default:mese", node.name)
end)
end)