v0.13.7
errors and warnings / stdlib

errors and warnings / stdlib / E8120

E8120 error

A @cases case does not match the test function's parameters

area
stdlib (x8xxx)
fails the build
yes

A case in @cases doesn't fit the parameters of the test function. Each case is a table of the arguments for one run (or a single value for a function with one parameter). A case is reported when it has more values than the function takes, when it lacks a value for a parameter that isn't optional, or when a value's type doesn't fit its parameter.

Example

× failstests/main.test.wowluawowlua
import test, cases, expect from "wowlua:test" @test("doubles")@cases({ { 1, 2 }, { 2, "4" } })local function doubles(n: number, expected: number)    expect(n * 2).toBe(expected)end
✓ compilestests/main.test.wowluawowlua
import test, cases, expect from "wowlua:test" @test("doubles")@cases({ { 1, 2 }, { 2, 4 } })local function doubles(n: number, expected: number)    expect(n * 2).toBe(expected)end

The compiler reports it like this:

error[E8120]: case 2: `"4"` is not assignable to `number` (parameter `expected`)
  ┌─ tests/main.test.wowlua:4:25
  │
4 │ @cases({ { 1, 2 }, { 2, "4" } })
  │                         ^^^ here
codemessage
E2001Type mismatch: S is not assignable to T

Offline

terminal
$ wowlua explain E8120
E8120 (error): A @cases case does not match the test function's parameters

source on GitHub ↗