conformance_test/positive_tests added
[deliverable/titan.core.git] / conformance_test / positive_tests / 13_messages / 13_toplevel / Sem_13_declaring_msg_008.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:24, Ensure instances of messages can be declared and passed via template parameter
13 ** @verdict pass accept, ttcn3verdict:pass
14 ***************************************************/
15 /*
16 * #reqname /Requirements/13 Declaring messages/Sorts of message insances/Template parameter as a message
17 **/
18
19
20 module Sem_13_declaring_msg_008 {
21 type record CompositeType{
22 integer i
23 }
24
25 type set MySet{
26 integer int1,
27 charstring str1
28 }
29
30 type enumerated MyEnum{
31 Perl,Bash,Python
32 }
33
34 type integer MyArray[3];
35
36 type union MyUnion{
37 integer int,
38 float real
39 }
40
41 type record MsgType1{
42 integer i,
43 float k,
44 boolean b,
45 verdicttype v,
46 bitstring bs,
47 hexstring hs,
48 octetstring os,
49 charstring cs,
50 universal charstring ucs,
51 CompositeType rec1,
52 MySet set1,
53 MyUnion union1,
54 MyEnum enum1,
55 MyArray arr1
56 }
57
58 type record MsgType2{
59 integer j
60 }
61
62 type port MyPort1 message{
63 out MsgType1;
64 in MsgType2;
65 } with {extension "internal"}
66
67 type port MyPort2 message{
68 out MsgType2;
69 in MsgType1;
70 } with {extension "internal"}
71
72 type component Sender{
73 port MyPort1 src;
74 }
75
76 type component Receiver{
77 port MyPort2 dst;
78 }
79
80 type component MTC {}
81
82 function make_union() return MyUnion
83 {
84 var MyUnion result;
85 result.int := 1;
86 return result;
87 }
88
89 const MsgType1 c_message := {
90 i := 1,
91 k := 1.0,
92 b := true,
93 v := pass,
94 bs := '0101'B,
95 hs := '123ABD'H,
96 os := 'FF96'O,
97 cs := """ab""",
98 ucs := "the",
99 rec1 := {i:=1},
100 set1 := {int1:=1, str1:="the"},
101 union1 := {int := 1},
102 enum1 := Bash,
103 arr1 := {1,2,3}
104 };
105
106 template MsgType1 global:= {i := 1, k:=1.0, b:=true, v:=pass, bs:='0101'B, hs:='123ABD'H,
107 os:='FF96'O, cs:="""ab""", ucs:="the", rec1:={i:=1}, set1:={int1:=1, str1:="the"}, union1 := make_union(), enum1:=Bash, arr1:={1,2,3} };
108
109 function f_sender(template MsgType1 v_template_message) runs on Sender
110 {
111 src.send(v_template_message);
112 }
113
114 function f_receiver() runs on Receiver
115 {
116 var MsgType1 v_message;
117 timer t_timer := 3.0;
118 t_timer.start;
119 alt
120 {
121 [] dst.receive(global) -> value v_message { setverdict(pass); }
122 [] t_timer.timeout { setverdict(fail); }
123 }
124 }
125
126 testcase TC_Sem_13_declaring_msg_008() runs on MTC system MTC
127 {
128 var template MsgType1 v_template_message := {
129 i := 1, k:=1.0, b:=true, v:=pass,
130 bs:='0101'B, hs:='123ABD'H,
131 os:='FF96'O, cs:="""ab""", ucs:="the",
132 rec1:={i:=1}, set1:={int1:=1, str1:="the"},
133 union1 := make_union(),
134 enum1:=Bash, arr1:={1,2,3}
135 };
136 var Sender c_sender := Sender.create;
137 var Receiver c_receiver := Receiver.create;
138 connect(c_sender:src, c_receiver:dst);
139 c_sender.start(f_sender(v_template_message));
140 c_receiver.start(f_receiver());
141 c_sender.done;
142 c_receiver.done;
143 }
144 control{
145
146 execute(TC_Sem_13_declaring_msg_008())
147
148
149 }
150 }
This page took 0.033895 seconds and 5 git commands to generate.