Assertions involving NaN

I use ounit to test the code of my lexer + parser. I have test input which should result in a NaN; I don’t know how to test this because NaN != NaN , so assert_equal will fail :frowning:


Try Float.is_nan. See OCaml library : Float.

1 Like

Thanks, that helped.

You can also use x y = 0 instead of x = y. compares NaNs equal and Nan and non-NaN different.