Next: , Previous: , Up: Other statements   [Contents][Index]

4.8.1 Asserting conditions

coNCePTuaL programs can encode the run-time conditions that must hold in order for the test to run properly. This is achieved through assertions, which are expressed as follows:

<assert_stmt> ::= ASSERT THAT <string>
WITH <rel_expr>

<string> is a message to be reported to the user if the assertion fails. <rel_expr> is a relational expression (as described in Relational expressions) that must evaluate to TRUE for the program to continue running. Assertion failures are considered fatal errors. They cause the coNCePTuaL program to abort immediately.

Here are some sample <assert_stmt>s:

ASSERT THAT "the bandwidth test requires at least two tasks" WITH
num_tasks >= 2

ASSERT THAT "pairwise ping-pongs require an even number of task"
WITH num_tasks IS EVEN

ASSERT THAT "this program requires a square number of tasks" WITH
SQRT(num_tasks)**2 = num_tasks

(For the last example, recall that coNCePTuaL expressions are of integer type. Hence, the example’s <rel_expr> is mathematically equivalent to floor(sqrt(N))^2 = N, which is TRUE if and only if N is a square.)

Scott Pakin,