require_allocation_does_not_exceed
is a specialized form of require
that only produces output when f ()
allocates more than the given limits. The output will include the actual number of major and minor words allocated. We do NOT include these numbers in the successful case because those numbers are not stable with respect to compiler versions and build flags.
If f
returns a value that should be ignored, use this idiom:
ignore (require_allocation_does_not_exceed ... f : t)
rather than this idiom:
require_allocation_does_not_exceed ... (fun () -> ignore (f () : t))
With the latter idiom, the compiler may optimize the computation of f ()
taking advantage of the fact that the result is ignored, and eliminate allocation that is intended to be measured. With the former idiom, the compiler cannot do such optimization and must compute the result of f ()
.
There is no ?cr:CR.t
argument, because one should not release a test with a failing call, due to instability across compiler optimization levels. Even if a test allocates too much without much optimization, it may allocate less with more optimization.