Isapprox in tests and a more precise result / reason for failure

@test a ≈ b has special support for :

julia> @test 0.0 ≈ 1e-7 atol=1e-7
Test Passed

julia> @test 0.0 ≈ 1e-7 atol=1e-8
Test Failed at REPL[13]:1
  Expression: ≈(0.0, 1.0e-7, atol = 1.0e-8)
   Evaluated: 0.0 ≈ 1.0e-7 (atol=1.0e-8)
ERROR: There was an error during testing

It might be nice to update the @test macro to print out more information on an test failure, e.g. giving the absolute and/or relative error (for atol and/or rtol tests, respectively).

Update: filed report error magnitude on @test x ≈ y failure · Issue #55613 · JuliaLang/julia · GitHub

5 Likes