← Lua Academy

Testing the platform · 56 / 69

Expect a type error

YOUR TASK

Make this happen

3 steps
  1. Some type exercises succeed when invalid code is rejected. Change the valid cache call into one that passes a number instead of a string. The academy checks for the precise type.bad-argument diagnostic and never executes this snippet.

  2. Read the cases in lesson.test.lua, then choose Check solution to see what needs to change.

  3. Update subject.lua until every test passes. Keep the supplied tests unchanged.

Read the starter and tests

subject.lua

return ctx.cache.get("valid")

lesson.test.lua

-- This exercise checks for type.bad-argument without executing code.