Typed Lua · 32 / 69
Respect named fields
YOUR TASK
Make this happen
Record fields carry their own types. A quantity should remain numeric even when it comes from a form or document.
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.line = function(): { sku: string, quantity: number }
return { sku = "PAPER", quantity = "2" }
end
lesson.test.lua
local t = require("test")
local subject = require("cococo.subject")
t.it("typed line", function()
local s = subject.load()
t.expect(s.line()):deep_eq({ sku = "PAPER", quantity = 2 })
end)