Test-driven development · 43 / 69
Compare calculated decimals
YOUR TASK
Make this happen
Floating-point arithmetic can introduce tiny rounding differences. near expresses a deliberate numeric tolerance; it does not excuse a substantially wrong calculation.
Read the cases in
lesson.test.lua, then choose Check solution to see what needs to change.Update
subject.luauntil every test passes. Keep the supplied tests unchanged.
Read the starter and tests
subject.lua
exports.third = function(): number return 0.3 end
lesson.test.lua
local t = require("test")
local subject = require("cococo.subject")
t.it("one third", function()
local s = subject.load()
t.expect(s.third()):near(0.333333333333, 0.000000001)
end)