Efficient use of test or assert

  • @test is very slow and for tests.
  • @assert is for double-checking invariants you are certaint are true. The only way it can fire, is when there are bugs in the program. E.g.
# good
y = _my_fast_sum_of_squares(xs)
@assert y >= 0
# bad
function public_api(x)
    @assert x >= 0
end
  • ArgCheck.jl is specifically designed for fast argument checks with nice error messages.
4 Likes