I wrote most of my unit test with the help of the unittest
module, but I’m not sure how to use it for code that the compiler should reject at compile time. For example, if I want to write the following code and make sure the compiler always errors during compilation (the type and template would be in a separate module), how do I write a test case for this?
import macros
type
T[n:static[int]] = object
template foo3(n: int): expr =
static:
if n > 3: error "n > 3"
type T3 = T[n]
T3
var
bar: foo3(4)