This commit is contained in:
Mrrp 2024-12-10 16:26:49 -08:00
parent 18e0963d89
commit ea726ced89
6 changed files with 46 additions and 26 deletions

39
tests/sanity_spec.lua Normal file
View file

@ -0,0 +1,39 @@
-- 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)
end)