2 Copyright (c) 2000-2014 Ericsson Telecom AB
4 All rights reserved. This program and the accompanying materials
5 are made available under the terms of the Eclipse Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/epl-v10.html
11 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8">
12 <meta http-equiv=
"Content-Language" content=
"en-us">
15 <body bgcolor=
"#DAD3C5" vlink=
"#0094D2" link=
"#003258">
16 <table align=
"left" border=
"0" cellspacing=
"0" cellpadding=
"0" valign=top
>
18 <td width=
105 height=
40><a href=
"https://projects.eclipse.org/projects/tools.titan"><img src=
"../images/titan_transparent.gif" border=
0 width=
105 height=
40 align=
"left" alt=
"Titan"></a></td>
21 <table border=
"0" align=
"right" cellpadding=
"0" cellspacing=
"0">
23 <td><a href=
"../titan_main.html" alt=
"contents"><img border=
"0" src=
"../images/ao.jpg" width=
"53" height=
"40"></a></td>
24 <td><a href=
"../titan_index.html" alt=
"index"><img border=
"0" src=
"../images/up.jpg" width=
"53" height=
"40"></a></td>
25 <td><a href=
"all.html" alt=
"previous"><img border=
"0" src=
"../images/left.jpg" width=
"53" height=
"40"></a></td>
26 <td><a href=
"altstep.html" alt=
"next"><img border=
"0" src=
"../images/right.jpg" width=
"53" height=
"40"></a></td>
33 <hr align=
"left" width=
"75%">
34 <p>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
35 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
36 (
"condition
") and end by an optional statement block.
38 <li>When entering an alt statement, a snapshot is taken. A new snapshot is triggered by the statement
<b><font face=
"Courier New" color=
"#003258" size=
"4">repeat
</font></b>.
</li>
39 <li>It is possible to enable/disable an alternative by means of a Boolean expression placed between the brackets of the alternative.
</li>
40 <li>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.
</li>
41 <li>alt statements may be nested.
</li>
43 <p>Related keywords:
</p>
45 <li><a href=
"repeat.html"><b><font face=
"Courier New" color=
"#003258" size=
"4">repeat
</font></b></a></li>
46 <li><a href=
"else.html"><b><font face=
"Courier New" color=
"#003258" size=
"4">else
</font></b></a></li>
48 <hr align=
"left" width=
"50%">
50 <table border=
"0" width=
"90%" bgcolor=
"#FFB599" cellpadding=
"4">
53 <h3 align=
"left"><font face=
"Courier New" color=
"#003258" size=
"5"><b>alt {
<br>
54 [
</b></font> [
<i>guard_expression
</i>]
<font face=
"Courier New" color=
"#003258" size=
"5"><b>]
</b></font> [
<i>condition
</i>]
<font face=
"Courier New" color=
"#003258" size=
"5"><b>{
</b></font>
55 [
<i>statement_block
</i>]
<font face=
"Courier New" color=
"#003258" size=
"5"><b>}
<br>
56 </b></font> ...
<font face=
"Courier New" color=
"#003258" size=
"5"><b><br>
57 };
</b></font> </h3>
64 <p>The
<font face=
"Courier New" color=
"#003258" size=
"4"><b>alt
</b></font> keyword introduces the branching definition.
</p>
67 <p>Each alternative begins with an optional
<i>guard_expression
</i> with the following options:
</p>
69 <li>empty guard (note that the brackets must be written) The
<i>statement_block
</i> will be executed if
<i>condition
</i> is met.
</li>
70 <li>Boolean expression. The
<i>statement_block
</i> will be executed if the Boolean expression evaluates to true AND
<i>condition
</i> is met.
</li>
72 <p><font face=
"Courier New" color=
"#003258" size=
"4"><b>else
</b></font> keyword. The
<i>statement_block
</i> will always be executed.
No
<i>condition
</i> may appear in the branch.
</p>
77 <p><i>condition
</i> may be a communication or a timer event or the termination of a parallel test component. The following operations may be written here:
<a href=
"receive.html"><b><font
78 face=
"Courier New" color=
"#003258" size=
"4">receive
</font></b></a>,
<a href=
"trigger.html"><b><font face=
"Courier New" color=
"#003258" size=
"4">trigger
</font></b></a>,
<a href=
"getcall.html"><b><font
79 face=
"Courier New" color=
"#003258" size=
"4">getcall
</font></b></a>,
<a href=
"getreply.html"><b><font face=
"Courier New" color=
"#003258" size=
"4">getreply
</font></b></a>,
<a href=
"catch.html"><b><font
80 face=
"Courier New" color=
"#003258" size=
"4">catch
</font></b></a>,
<a href=
"check.html"><b><font face=
"Courier New" color=
"#003258" size=
"4">check
</font></b></a>,
<a href=
"timeout.html"><b><font
81 face=
"Courier New" color=
"#003258" size=
"4">timeout
</font></b></a> and
<a href=
"done.html"><b><font face=
"Courier New" color=
"#003258" size=
"4">done
</font></b></a>.
</p>
84 <p>The optional
<i>statement_block
</i> contains one or more statements separated by semicolons. When empty, the curly brackets must be written.
</p>
87 <p><b>...
</b> indicates that
several branches may occur in the
<font face=
"Courier New" color=
"#003258" size=
"4"><b>alt
</b></font> body. There is no separator between them.
</p>
90 <hr align=
"left" width=
"50%">
92 <p><font face=
"Courier New">alt {
<br>
93 []
L1_PCO.receive { setverdict(pass) }
<br>
94 [x
<=
1] L2_PCO.receive { setverdict(inconc) }
<br>
95 [else]
{ setverdict(fail); stop }
<br>
97 <p>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
98 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
99 execution is stopped.
</p>
100 <hr align=
"left" width=
"25%">
101 <hr align=
"left" width=
"25%">
102 <p><a HREF=
"BNF.html#altconstruct">BNF definition
</a> of
<font face=
"Courier New"> alt
</font></p>