PROC

C++ Test Script Language

Syntax

PROC <procedure name> [ ( <formal parameter> [ ( , <formal parameter> ) ] ) ]

[ REQUIRE ( <native expression> ) ]

<procedure item>

[ ENSURE ( <native expression> ) ]

Location

TEST CLASS, TEST SUITE

Description

The PROC statement defines a procedure.

Note Procedures can be called with the CALL statement.

<procedure name> is a C++ Test Script Language identifier. It is visible in the surrounding test class or test suite, in sub-test classes or sub-test suites, and in inheriting test classes.

<formal parameter> is a C++ Test Script Language identifier. It has no type: it is replaced into the procedure by an actual parameter. Thus it can refer to a C++ type as well a C++ constant or a C++ variable.

<native expression> is a C++ expression that can be evaluated to a Boolean. The REQUIRE expression is evaluated before execution of the procedure. The ENSURE expression is evaluated after execution of the procedure. If any of these optional expressions is False, the evaluation leads to an error in the caller's context.

<procedure item> may be one the following entities:

  • CHECK EXCEPTION

  • CHECK

  • CHECK PROPERTY

  • CALL

  • CHECK STUB

  • CHECK METHOD

  • ON ERROR

  • COMMENT

  • PRINT

  • Native statement

Order is meaningful, except for CHECK STUB, CHECK METHOD, and ON ERROR statements.

The ON ERROR statement may only appear once.

Example

TEST CLASS TestA {

PROC InitArray (array, length)

REQUIRE (length>30 && length<array.length())

{

#{

for (int i = 0; i<length; i++)

array[i].init ();

}#

}

ENSURE (array[0].initialized())

}