assert expression is a debugging feature that you can use to test an expression. Upon failure in Debug mode, an assertion generates a system error dialog box.
assert expression has type
bool -> unit.
Assertion checking is enabled only when you compile in Debug mode; that is, if the constant
DEBUG is defined. In the project system, by default, the
DEBUG constant is defined in the Debug configuration but not in the Release configuration.
The assertion failure error cannot be caught by using F# exception handling.
The following code example illustrates the use of the
let subtractUnsigned (x : uint32) (y : uint32) = assert (x > y) let z = x - y z // This code does not generate an assertion failure. let result1 = subtractUnsigned 2u 1u // This code generates an assertion failure. let result2 = subtractUnsigned 1u 2u