Voxelis/tests/sanity.lua
DesertMermaid a7ac9c29b2
Some checks failed
Unit Tests / busted_unit_test (push) Failing after 48s
Error Check / luacheck_errcheck (push) Failing after 50s
new file: .forgejo/workflows/error_check.yml
new file:   .forgejo/workflows/unit_test.yml
new file:   .luacheckrc
new file:   .vscode/settings.json
new file:   LICENSE
new file:   default.nix
modified:   game.conf
modified:   minetest.conf
new file:   mods/BLOCKS/modpack.conf
new file:   mods/BLOCKS/overworld/init.lua
new file:   mods/BLOCKS/overworld/mod.conf
new file:   mods/BLOCKS/overworld/textures/vox_grass.png
new file:   mods/COMPAT/README.md
new file:   mods/COMPAT/minetest_default/README.md
new file:   mods/COMPAT/minetest_default/init.lua
new file:   mods/COMPAT/minetest_default/mod.conf
new file:   mods/COMPAT/modpack.conf
new file:   mods/CORE/colors/init.lua
new file:   mods/CORE/colors/mod.conf
new file:   mods/CORE/controls
new file:   mods/CORE/modpack.conf
new file:   mods/CORE/vox_main/init.lua
new file:   mods/CORE/vox_main/mod.conf
new file:   mods/ENTITIES/modpack.conf
new file:   mods/ENVIRONMENT/modpack.conf
new file:   mods/HELP/modpack.conf
new file:   mods/HUD/inventory/creative.lua
new file:   mods/HUD/inventory/init.lua
new file:   mods/HUD/inventory/mod.conf
new file:   mods/HUD/inventory/survival.lua
new file:   mods/HUD/modpack.conf
new file:   mods/ITEMS/modpack.conf
new file:   mods/MAPGEN/modpack.conf
new file:   mods/MISC/modpack.conf
new file:   mods/PLAYER/modpack.conf
modified:   settingtypes.txt
new file:   tests/CORE/colors.lua
new file:   tests/README.md
new file:   tests/sanity.lua
2024-12-10 15:23:36 -08:00

45 lines
No EOL
1.7 KiB
Lua

-- A test that should obviously always pass, regardless of the rest of the project
-- Otherwise, something is very wrong
-- Intended as a "canary test" for tooling
-- For documentation about the assertions, see https://lunarmodules.github.io/busted/#asserts and https://github.com/lunarmodules/luassert
-- Some information about how to use this framework with Luanti is also available at https://rubenwardy.com/minetest_modding_book/en/quality/unit_testing.html
function returns_error()
error("This is an error")
end
function returns_nothing()
return
end
function returns_something()
return 42
end
describe("sanitytest", function()
it("tests basic equality", function()
assert.are.equal(2 + 2, 4, "Equality: 2 + 2 should equal 4")
assert.are_not.equals(2 + 2, 5, "Inequality: 2 + 2 should not equal 5")
end)
it("tests error handling", function()
assert.has_error(returns_error, "This is an error", "Error handling: returns_error should throw an error")
end)
it("tests return values", function()
assert.is_nil(returns_nothing(), "Return value: returns_nothing should return nil")
assert.is_not_nil(returns_something(), "Return value: returns_something should return something")
end)
it("tests truthiness", function()
assert.is_true(true, "Truthiness: true should be true")
assert.is_false(false, "Truthiness: false should be false")
end)
it("tests properties", function()
assert.has_property({a = 1, b = 2}, "a", "Properties: table should have property a")
assert.has_no_property({a = 1, b = 2}, "c", "Properties: table should not have property c")
end)
end)