# interleave

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 sequence of the events does not matter. The individual alternatives (or branches) contain an event or "receiving operation", which can be successful or unsuccessful ("condition") and end by an optional statement block.

Opposed to alt statement, where only a single alternative is taken, all branches of the interleave statement must "happen".

Related keyword:

- alt

### interleave { [] [condition] { [statement_block] } ... };

- The interleave keywords introduces the branching definition.

- Each branch begins with a pair of brackets (the brackets must be empty).

- 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, 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.

  The use of iterative statements (for, while, do-while, etc.) is forbidden inside the statement block.

  Neither direct altstep invocation, nor default activation are permitted.

  Function calls, which contain communication operations, shall also be avoided inside the statement block of interleave statement.

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

Example:

interleave {
[] L1_PCO.receive (tr_Sig1)
{
L1_PCO.send (t_Sig2);
L1_PCO.receive(tr_Sig3)
}
[] L2_PCO.receive (tr_Sig4)
{
L2_PCO.send (t_Sig5);
L2_PCO.receive(tr_Sig6);
L2_PCO.send (t_Sig7)
}
};

The reception events on ports L1_PCO and L2_PCO may happen in arbitrary order. The possible orderings of incoming messages are:

`tr_Sig1, tr_Sig3, tr_Sig4, tr_Sig6
tr_Sig1, tr_Sig4, tr_Sig3, tr_Sig6
tr_Sig1, tr_Sig4, tr_Sig6, tr_Sig3
tr_Sig4, tr_Sig1, tr_Sig3, tr_Sig6
tr_Sig4, tr_Sig1, tr_Sig6, tr_Sig3
tr_Sig4, tr_Sig6, tr_Sig1, tr_Sig3`

BNF definition of interleave