The relational operators compare the first operand to the second, to test the condition that the operator specifies.
Equality | == | Tests whether the operands are equal; returns TRUE if they are equal and FALSE otherwise. For lists and arrays, each element must be equal to its corresponding element; for records, each field must compare equal to its corresponding field to evaluate to TRUE. For data classes, the operator evaluates to TRUE if the classes are compatible, meaning that the classes are the same, or that one of the classes is a subclass of the other. |
Inequality | != | Tests whether the operands are not equal; returns TRUE if they are unequal, FALSE otherwise. For lists, arrays, and records, if one set of corresponding elements or fields is not equal, returns TRUE. |
Greater Than | > | Tests whether the value of the first operand is greater than the value of the second; returns TRUE if it is, and FALSE otherwise. |
Greater Than or Equal | >= | Tests whether the value of the first operand is greater than or equal to the value of the second; returns TRUE if it is, and FALSE otherwise |
Less Than | < | Tests whether the value of the first operand is less than the value of the second; returns TRUE if it is, and FALSE otherwise. |
Less Than or Equal | <= | Tests whether the value of the first operand is less than or equal to the value of the second; returns TRUE if it is, and FALSE otherwise. |
The operands to relational operators can have any of the base 4Test simple types. The equality and inequality operators can also take compound types, such as lists, arrays, and records.
Relational operators all return BOOLEAN values.
The following code compiles in C, but not in 4Test:
if ((i=5) == TRUE)
This difference is intentional. Because this construct can lead to unreadable code, 4Test does not allow it.