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
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)endimport 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)endThe 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
Related codes
| code | message |
|---|---|
| E2001 | Type mismatch: S is not assignable to T |
Offline
$ wowlua explain E8120 E8120 (error): A @cases case does not match the test function's parameters