# alt

The statement denotes branching of test behavior due to the reception and handling of communication and/or timer events and/or the termination of parallel test components. The individual alternatives (or branches) begin with a Boolean guard enabling or disabling the alternative (default is true), continue with an event or Ã¢â¬Åreceiving operationÃ¢â¬ï¿½, which can be successful or unsuccessful ("condition") and end by an optional statement block.

- When entering an alt statement, a snapshot is taken. A new snapshot is triggered by the statement repeat.
- It is possible to enable/disable an alternative by means of a Boolean expression placed between the brackets of the alternative.
- The last branch in an alt statement can be defined as an else branch by including the else keyword between the brackets of the alternative.
- alt statements may be nested.

Related keywords:

- repeat
- else

### alt {
[ [guard_expression] ] [condition] { [statement_block] }
...
};

- The alt keyword introduces the branching definition.

- Each alternative begins with an optional guard_expression with the following options:

  - empty guard (note that the brackets must be written) The statement_block will be executed if condition is met.
  - Boolean expression. The statement_block will be executed if the Boolean expression evaluates to true AND condition is met.

  - else keyword. The statement_block will always be executed. No condition may appear in the branch.

- condition may be a communication or a timer event or the termination of a parallel test component. The following operations may be written here: receive, trigger, getcall, getreply, catch, check, timeout and done.

- The optional statement_block contains one or more statements separated by semicolons. When empty, the curly brackets must be written.

- ... indicates that several branches may occur in the alt body. There is no separator between them.

Example:

alt {
[] L1_PCO.receive { setverdict(pass) }
[x<=1] L2_PCO.receive { setverdict(inconc) }
[else] { setverdict(fail); stop }
};

The first branch is activated if a message has been received on port L1_PCO. The verdict is set to pass. The second branch is activated if a message has been received on port L2_PCO and the variable x is not grater then one. In this case the verdict is set to inconclusive. The last branch is activated if none of the ports has received a messages. The verdict is set to fail and test execution is stopped.

BNF definition of alt