better docs/error reporting

This commit is contained in:
Michael Freno
2025-11-17 09:28:41 -05:00
parent d7ace1d535
commit a8be1f5342
5 changed files with 313 additions and 149 deletions

View File

@@ -22,28 +22,25 @@ function TestAnimation:testNewWithNilDuration()
end
function TestAnimation:testNewWithNegativeDuration()
-- Should still create but behave oddly
local anim = Animation.new({
duration = -1,
start = { opacity = 0 },
final = { opacity = 1 },
})
luaunit.assertNotNil(anim)
-- Update with positive dt should immediately finish
local done = anim:update(1)
luaunit.assertTrue(done)
-- Should throw an error for invalid duration
luaunit.assertErrorMsgContains("duration must be a positive number", function()
Animation.new({
duration = -1,
start = { opacity = 0 },
final = { opacity = 1 },
})
end)
end
function TestAnimation:testNewWithZeroDuration()
local anim = Animation.new({
duration = 0,
start = { opacity = 0 },
final = { opacity = 1 },
})
luaunit.assertNotNil(anim)
-- Should be instantly complete
local done = anim:update(0.001)
luaunit.assertTrue(done)
-- Should throw an error for invalid duration
luaunit.assertErrorMsgContains("duration must be a positive number", function()
Animation.new({
duration = 0,
start = { opacity = 0 },
final = { opacity = 1 },
})
end)
end
function TestAnimation:testNewWithInvalidEasing()