forked from mad-star-studio/Voxelis
39 lines
1.4 KiB
Lua
39 lines
1.4 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)
|
||
|
end)
|