Previous Topic: arrdump Command--Display an Array (Cmdlet)Next Topic: cat, type Commands--Display Text Files (Cmdlets)


ASSERT Command--Compare Mathematical Expressions (Funclet)

This command (funclet) checks if the statement or assertion that consists of two mathematical expressions and an operation is true or false. The mathematical expressions can be composed of the following elements:

If the statement or assertion is false, AutoShell raises a customizable error message.

To write numbers in octal format, precede the value with a 0, for example, 0123. To write numbers in hexadecimal format, precede the value with a 0x, for example, 0x123.

The command has the following syntax:

ASSERT x relation v [-msg msg]
x

Defines a mathematical expression that is compared against the expression v.

relation

Specifies the relation used for the comparison. Options include the following:

v

Defines a mathematical expression.

-msg msg

(Optional) Defines an alternative error message instead of the default error message raised when the comparison returns false.

Default: null

Examples

Show that the statement 6>7 is wrong:

ASSERT 6 gt 7 -msg "This is wrong."
This is wrong.

Verifies if the octal value 0123 is equal to 0x9e:

ASSERT 0123 eq 0x9e
Failed: 0123==158, actual=83

Check if PI is greater than 4.5*sin(PI/2):

ASSERT Math.PI gt 4.5*Math.sin(Math.PI/2)
Failed: Math.PI>4.5, actual=3.141592653589793