next | previous | forward | backward | up | top | index | toc | Macaulay2 website
Macaulay2Doc :: assert

assert -- assert something is true

Synopsis

Description

assert x prints an error message if x isn't true.

i1 : assert( (2+2) === 4)
i2 : assert(rank matrix {{1, 2}, {2, 4}} == 2)
stdio:2:1:(3): error: assertion failed

If x is an Expression that evaluates to false, then a partially evaluated form is printed with the error message to assist in debugging.

i3 : assert Equation(rank matrix {{1, 2}, {2, 4}}, 2)
stdio:3:1:(3): error: assertion failed:
1 == 2 is false

See also

Ways to use assert :

For the programmer

The object assert is a method function.