How to test that a function returns the unit type?

If I want to make a test that ensures a function returns the unit type (so if I change the function signature the test breaks), how might I do this?

The unit type is described as (), but is there a unit value I can use in Motoko on the other end of the test to assert equivalence?

I think the unit value in Motoko is also (), so this works:

func foo() {};
assert (foo() == ());
1 Like

I forgot to say that you can also do this at the type level!

There’s no need for runtime assertions when the type checker can do it for you.

func foo() {};
let _ : () = foo();