It depends of what you mean by assert. You can define a debugf function with the Format module:
let debugf s test fmt =
if test then Format.ifprintf Format.err_formatter fmt
else begin
Format.eprintf "@[<v 2> %s:@," s;
Format.kfprintf
(fun ppf -> Format.fprintf ppf "@]@."; exit 2)
Format.err_formatter
fmt
end
which can be used with the __LOC__ variable to keep the location of the debug test in the message
No there is no such functions by default in the standard library; and there are many moving parts (where to print and how to exit in particular) in the function above that often make it better to customize for the use case at hand.