Open certik opened 5 months ago
One can emulate the statement assert(abs(x-y) < 1e-10_dp)
using a macro.
One could probably also emulate the subroutine call call assert(abs(x-y) < 1e-10_dp)
using a macro that would transform it into call assert_impl(expr="abs(x-y) < 1e-10_dp", filename="/path/to/test_file.f90", function="test_abs", line=134, cond=abs(x-y) < 1e-10_dp)
or something like that.
Related proposal and discussion: https://github.com/j3-fortran/fortran_proposals/issues/70
There are several approaches:
Fortran subroutine
We implement a Fortran function
assert
in a module, import a module and use it. That was done here:https://github.com/lfortran/lfortran/pull/3940
One can also consider providing floating point specific assert:
Intrinsic subroutine
Intrinsic statement