Ada Test Script Language


The STUB instruction for Ada describes all calls to a simulated function in a test script.


STUB <stub_name> [<call_range> =>] ([<param_val> {, <param_val> }]) [<return_val>] {, [<call_range> =>] ([<param_val> {, <param_val> }]) [<return_val>] }


The following is described for every parameter of this function and for every expected call:

<stub_name> is the name of the simulated procedure or function. It is obligatory. You must previously have described this procedure or function in a DEFINE STUB block.

The optional <call_range> describes one or several successive calls as follows:

<call_num> =>

<call_num> .. <call_num> =>

others =>


where <call_num> is the number of the stub call. The keyword others specifies the behavior of any further calls that have not been described. A <call_num> value of 0 means that no calls are expected to the stub. For example, the following line specifies that test will pass if there are 0 or more calls to the stub:

STUB close_file others=>(5)1


Moreover, you can use others to specify that the calls are optional. Combining others with a list of call numbers, enables you to check the minimum number of calls. For example, the following line specifies that test will pass if there are at least 2 calls to the stub:

STUB close_file 1=>(3)1, 2=>(4)1, others=>(5)1


If <call_range> is not specified, then the next call number is assumed. For example, the following lines specify that the test will pass if there are 2 calls to the stub:

STUB open_file ("file1")3

STUB open_file ("file2")4


<param_val> is an expression describing the test values for in parameters and the returned values for out parameters. If named, parameters can be in any order. For in out parameters, <param_val> is expressed in the following way:

( [IN =>]<in_param_val> , [OUT =>]<out_param_val> )


If you use the optional IN => and OUT => specifiers, you can invert the order of the parameters.

<return_val> is an expression describing the value returned by the function if its type is not void. Otherwise, no value is provided.

You must give values for every in, out and in out parameter; otherwise, a warning message is generated. The no parameters are ignored.

<param_val> and <return_val> are Ada expressions that can contain:

<param_val> can contain for an in value:

<param_val> can contain for an out value or return value:

If are using one of the above expressions, you can specify the type of parameter by using the ==: <type> syntax for the out and return value or <->: <type> for the in value.

<return_val> can also refer to an Ada exception name introduced by the following syntax:

[ :<return_type> ] RAISE <exception_name>


where :<return_type> is used to specify the function returned type in case of overloading.

You must describe at least one call in the STUB instruction. Several descriptions can occur separated by commas.

STUB instructions can appear in ELEMENT blocks.


STUB open_file ("file1")3

STUB create_file ("file2")4

STUB read_file 1..2 =>(3,"line 1",1)1,(3,"line 2",2<->3)1,

 & 4..7 =>(3,"",0)0

STUB write_file (4,"line 1")1, (4,"line 2")1

STUB close_file (3)1,(4)1, (<->) RAISE DEVICE_ERROR


Related Topics