Testing expressions

Component Testing for Ada

To test the return value of an expression, rather than declaring a local variable to memorize the value under test, you can directly test the return value with the VAR instruction.

In some cases, you must leave out the initialization part of the instruction.


The following example places the call of the add function in a VAR statement:


 FAMILY nominal


  VAR a, init = 1, ev = init

  VAR b, init = 3, ev = init

  VAR add(a,b), ev = 4




In this example, you no longer need the variable c. The resulting test report an Unknown status indicating that it has not been tested.

All syntax examples of expected values are still applicable, even in this particular case.

Related Topics

Testing variablesTesting intervalsTesting tolerancesInitializing without testing