conformance_test/positive_tests added
[deliverable/titan.core.git] / conformance_test / positive_tests / 22_communication_operations / 2203_procedure_based_communication / 220306_catch_operation / Sem_220306_catch_operation_005.ttcn
1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
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
7 *
8 * Contributors:
9 * Adrien Kirjak – initial implementation
10 *
11 ** @version 0.0.1
12 ** @purpose 1:22.3.6, Verify that any from done assigns index
13 ** @verdict pass accept, ttcn3verdict:pass
14 *****************************************************************/
15 // The following requirements are tested:
16 // It is also possible to store the index of a port in a single-dimensional port array at which
17 // the operation was successful to a variable of type integer or, in case of multi-dimensional
18 // port arrays the index of the successful port to an integer array or record of integer variable.
19 // When checking the port array for matching exceptions, the port indices to be checked are iterated
20 // from lowest to highest.
21 module Sem_220306_catch_operation_005 {
22
23 signature S() exception(integer);
24
25 type port P procedure {
26 inout S;
27 } with {extension "internal"}
28
29 const integer c_portCount := 4;
30 type component GeneralComp
31 {
32 port P p[c_portCount];
33 }
34
35 function f() runs on GeneralComp
36 {
37 for(var integer i := 0; i < c_portCount; i := i + 1) {
38 p[i].getcall;
39 if (i mod 2 == 1) { p[i].raise(S, i + 1); };
40 }
41 }
42
43 testcase TC_Sem_220306_catch_operation_005() runs on GeneralComp system GeneralComp {
44 var GeneralComp v_ptc := GeneralComp.create;
45 var integer v_index, v_res;
46
47 for(var integer i := 0; i < c_portCount; i := i + 1) {
48 connect(self:p[i], v_ptc:p[i]);
49 p[i].call(S:{}, nowait);
50 }
51
52 v_ptc.start(f());
53 v_ptc.done;
54
55 alt
56 {
57 [] any from p.catch(S, integer:(0..c_portCount)) -> value v_res @index v_index {
58 if(v_index == 1 and v_res == v_index + 1){
59 setverdict(pass);
60 } else {
61 setverdict(fail, "Index or parameter value incorrectly assigned");
62 }
63 }
64 [else] { setverdict(fail, "The any from catch operation didn't match for some reason"); }
65 }
66 }
67
68 control {
69 execute(TC_Sem_220306_catch_operation_005(), 5.0);
70 }
71 }
This page took 0.033394 seconds and 5 git commands to generate.