Commit | Line | Data |
---|---|---|
970ed795 | 1 | <!-- |
d44e3c4f | 2 | Copyright (c) 2000-2016 Ericsson Telecom AB |
970ed795 EL |
3 | All rights reserved. This program and the accompanying materials |
4 | are made available under the terms of the Eclipse Public License v1.0 | |
5 | which accompanies this distribution, and is available at | |
6 | http://www.eclipse.org/legal/epl-v10.html | |
d44e3c4f | 7 | |
8 | Contributors: | |
9 | Baji, Laszlo | |
10 | Balasko, Jeno | |
11 | Farkas, Laszlo | |
12 | Szabados, Kristof | |
13 | Szabo, Janos Zoltan – initial implementation | |
14 | --> | |
970ed795 EL |
15 | <html> |
16 | <head> | |
17 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
18 | <meta http-equiv="Content-Language" content="en-us"> | |
19 | <title>alt</title> | |
20 | </head> | |
21 | <body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258"> | |
22 | <table align="left" border="0" cellspacing="0" cellpadding="0" valign=top> | |
23 | <tr> | |
24 | <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> | |
25 | </tr> | |
26 | </table> | |
27 | <table border="0" align="right" cellpadding="0" cellspacing="0"> | |
28 | <tr> | |
29 | <td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td> | |
30 | <td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td> | |
31 | <td><a href="all.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> | |
32 | <td><a href="altstep.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td> | |
33 | </tr> | |
34 | </table> | |
35 | <p><br clear="all"> | |
36 | </p> | |
37 | <hr> | |
38 | <h1>alt</h1> | |
39 | <hr align="left" width="75%"> | |
40 | <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 | |
d44e3c4f | 41 | alternatives (or branches) begin with a Boolean guard enabling or disabling the alternative (default is true), continue with an event or ââ\82¬Å\93receiving operationââ\82¬ï¿½, which can be successful or unsuccessful |
970ed795 EL |
42 | ("condition") and end by an optional statement block. |
43 | <ul> | |
44 | <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> | |
45 | <li>It is possible to enable/disable an alternative by means of a Boolean expression placed between the brackets of the alternative.</li> | |
46 | <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> | |
47 | <li>alt statements may be nested.</li> | |
48 | </ul> | |
49 | <p>Related keywords:</p> | |
50 | <ul> | |
51 | <li><a href="repeat.html"><b><font face="Courier New" color="#003258" size="4">repeat</font></b></a></li> | |
52 | <li><a href="else.html"><b><font face="Courier New" color="#003258" size="4">else</font></b></a></li> | |
53 | </ul> | |
54 | <hr align="left" width="50%"> | |
55 | <div align="center"> | |
56 | <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> | |
57 | <tr> | |
58 | <td width="100%"> | |
59 | <h3 align="left"><font face="Courier New" color="#003258" size="5"><b>alt {<br> | |
60 | [</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> | |
61 | [<i>statement_block</i>] <font face="Courier New" color="#003258" size="5"><b>}<br> | |
62 | </b></font> ...<font face="Courier New" color="#003258" size="5"><b><br> | |
63 | };</b></font> </h3> | |
64 | </td> | |
65 | </tr> | |
66 | </table> | |
67 | </div> | |
68 | <ul> | |
69 | <li> | |
70 | <p>The <font face="Courier New" color="#003258" size="4"><b>alt</b></font> keyword introduces the branching definition.</p> | |
71 | </li> | |
72 | <li> | |
73 | <p>Each alternative begins with an optional <i>guard_expression</i> with the following options:</p> | |
74 | <ul> | |
75 | <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> | |
76 | <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> | |
77 | <li> | |
78 | <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> | |
79 | </li> | |
80 | </ul> | |
81 | </li> | |
82 | <li> | |
83 | <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 | |
84 | 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 | |
85 | 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 | |
86 | 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 | |
87 | 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> | |
88 | </li> | |
89 | <li> | |
90 | <p>The optional <i>statement_block</i> contains one or more statements separated by semicolons. When empty, the curly brackets must be written.</p> | |
91 | </li> | |
92 | <li> | |
93 | <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> | |
94 | </li> | |
95 | </ul> | |
96 | <hr align="left" width="50%"> | |
97 | <p>Example: | |
98 | <p><font face="Courier New">alt { <br> | |
99 | [] L1_PCO.receive { setverdict(pass) } <br> | |
100 | [x<=1] L2_PCO.receive { setverdict(inconc) } <br> | |
101 | [else] { setverdict(fail); stop } <br> | |
102 | };</font> | |
103 | <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 | |
104 | 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 | |
105 | execution is stopped.</p> | |
106 | <hr align="left" width="25%"> | |
107 | <hr align="left" width="25%"> | |
108 | <p><a HREF="BNF.html#altconstruct">BNF definition</a> of <font face="Courier New"> alt</font></p> | |
109 | </body> | |
110 | </html> |