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 ![]()
–
Ian
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 ![]()
–
Ian
Try Float.is_nan. See OCaml library : Float.
Thanks, that helped.
You can also use Float.compare x y = 0 instead of x = y. Float.compare compares NaNs equal and Nan and non-NaN different.