Testing the platform · 55 / 69
Move time without waiting
YOUR TASK
Make this happen
The testing clock is controlled by the test. Advance milliseconds instantly to test elapsed time. There is no real wait, and the result is repeatable. Implement elapsed(start) using the granted time capability.
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.elapsed = function(start: number): number return 0 end
lesson.test.lua
local t = require("test")
local subject = require("cococo.subject")
t.it("elapsed milliseconds", function()
t.clock.set(1000)
local start = time.now():epoch_millis()
t.clock.advance(2500)
t.expect(subject.load().elapsed(start)):eq(2500)
end)