Update README.md
[deliverable/titan.core.git] / help / info / alt.html
1 <!--
2 Copyright (c) 2000-2014 Ericsson Telecom AB
3
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
8 -->
9 <html>
10 <head>
11 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
12 <meta http-equiv="Content-Language" content="en-us">
13 <title>alt</title>
14 </head>
15 <body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258">
16 <table align="left" border="0" cellspacing="0" cellpadding="0" valign=top>
17 <tr>
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>
19 </tr>
20 </table>
21 <table border="0" align="right" cellpadding="0" cellspacing="0">
22 <tr>
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>
27 </tr>
28 </table>
29 <p><br clear="all">
30 </p>
31 <hr>
32 <h1>alt</h1>
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 (&quot;condition&quot;) and end by an optional statement block.
37 <ul>
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>
42 </ul>
43 <p>Related keywords:</p>
44 <ul>
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>
47 </ul>
48 <hr align="left" width="50%">
49 <div align="center">
50 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
51 <tr>
52 <td width="100%">
53 <h3 align="left"><font face="Courier New" color="#003258" size="5"><b>alt {<br>
54 &nbsp;&nbsp;&nbsp; [</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 &nbsp;&nbsp;&nbsp; </b></font> ...<font face="Courier New" color="#003258" size="5"><b><br>
57 };</b></font> &nbsp;</h3>
58 </td>
59 </tr>
60 </table>
61 </div>
62 <ul>
63 <li>
64 <p>The <font face="Courier New" color="#003258" size="4"><b>alt</b></font> keyword introduces the branching definition.</p>
65 </li>
66 <li>
67 <p>Each alternative begins with an optional <i>guard_expression</i> with the following options:</p>
68 <ul>
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.&nbsp;</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>
71 <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.&nbsp; No <i>condition</i> may appear in the branch.</p>
73 </li>
74 </ul>
75 </li>
76 <li>
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>
82 </li>
83 <li>
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>
85 </li>
86 <li>
87 <p><b>...</b> indicates that&nbsp; 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>
88 </li>
89 </ul>
90 <hr align="left" width="50%">
91 <p>Example:
92 <p><font face="Courier New">alt {&nbsp;<br>
93 &nbsp;&nbsp;&nbsp;[]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;L1_PCO.receive { setverdict(pass) }&nbsp;<br>
94 &nbsp;&nbsp;&nbsp;[x&lt;=1] L2_PCO.receive { setverdict(inconc) }&nbsp;<br>
95 &nbsp;&nbsp;&nbsp;[else]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ setverdict(fail); stop }&nbsp;<br>
96 };</font>
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>
103 </body>
104 </html>
This page took 0.04809 seconds and 5 git commands to generate.