source: trunk/t3q-examples/PrettyPrintingAndFormatting-Preliminary/formattingTester.ttcn3 @ 58

Last change on this file since 58 was 4, checked in by phdmakk, 14 years ago
File size: 5.2 KB
Line 
1module formattingTester {
2
3//module parameters
4modulepar boolean mp_boolean := true;
5modulepar { integer mp_int1, mp_int2 := 2; integer mp_int3 := 3;}
6
7
8//full function body with multiple parameters, including passing modes, runs on clause and return value
9function f_sample2 (
10  template R3Msg p_radiusAccntReq,
11  out template R3Msg p_radiusAccntRsp )
12runs on R3Comp
13return FncRetCode {
14  var FncRetCode v_ret := e_success;
15
16  alt {
17    [] r3Port.receive ( m_r3MonitorInd ( p_radiusAccntReq ) ) {
18      v_ret := e_success;
19    }
20    [] r3Port.receive ( m_r3MonitorInd (
21                          e_RadiusAccountingRequest,
22                          p_radiusAccntReq ) ) {
23      v_ret := e_success;
24    }
25    [] r3Port.receive ( m_r3MonitorInd (
26                          e_RadiusAccountingRequest,
27                          m_radiusAccntReq_any ) ) {
28      return e_error;
29    }
30  }
31  return v_ret;
32}   
33//function skeleton with a single parameter, including a passing mode, with a runs on clause
34function f_sample1 (in template R3Msg p_radiusAccntReq)
35        runs on R3Comp {
36}
37
38//function skeleton with a single parameter, with a runs on clause
39function f_sample11 (template R3Msg p_radiusAccntReq)
40        runs on R3Comp {
41}
42
43//function skeleton without parameters, with a return value
44function f_sample ()
45        return r {
46}
47
48//full function body with multiple parameters, including passing modes, no further clauses
49function f_sample21(
50  template R3Msg p_radiusAccntReq,
51  out template R3Msg p_radiusAccntRsp ) {
52
53  var integer v_var1 := 0;
54  var integer v_var2 := 10;
55 
56  while (v_var1 < v_var2){
57        v_var1:=v_var1+1;
58  }
59 
60}
61
62
63//altstep skeleton without parameters
64altstep a_sample ()
65        runs on R3Comp {
66}
67
68//altstep with full body, multiple parameters, with passing modes and a runs on clause
69
70altstep a_sample2 ( template R3Msg p_radiusAccntReq, inout template R3Msg p_radiusAccntRsp )
71        runs on R3Comp {
72
73[] r3Port.receive ( m_r3MonitorInd ( p_radiusAccntReq ) ) {
74      v_ret := e_success;
75    }
76    [] r3Port.receive ( m_r3MonitorInd (
77                          e_RadiusAccountingRequest,
78                          p_radiusAccntReq ) ) {
79      v_ret := e_success;
80    }
81 }
82
83
84//altstep skeleton with a single parameter
85altstep a_sample1 (template R3Msg p_radiusAccntReq) {
86}
87
88//sample test case with full body, multiple parameters, with modifiers, runs on and system clauses
89testcase tc_sample2 (
90  template R3Msg p_radiusAccntReq,
91  out template R3Msg p_radiusAccntRsp )
92runs on R3Comp
93system R3System {
94  var FncRetCode v_ret := e_success;
95
96  alt {
97    [] r3Port.receive ( m_r3MonitorInd ( p_radiusAccntReq ) ) {
98      v_ret := e_success;
99    }
100    [] r3Port.receive ( m_r3MonitorInd (
101                          e_RadiusAccountingRequest,
102                          p_radiusAccntReq ) ) {
103      v_ret := e_success;
104    }
105    [] r3Port.receive ( m_r3MonitorInd (
106                          e_RadiusAccountingRequest,
107                          m_radiusAccntReq_any ) ) {
108    }
109    [] a_sample2 (m_r3MonitorInd,m_r3MonitorInd);
110    [] a_sample1 (m_r3MonitorInd);
111    [] a_sample0 ();
112  }
113
114}   
115//sample test case skeleton with a single parameter, including a passing mode, with a runs on clause
116testcase tc_sample1 (in template R3Msg p_radiusAccntReq)
117        runs on R3Comp {
118}
119
120//test tcase skeleton with a single parameter, with a runs on clause and a system clause
121testcase tc_sample11 (template R3Msg p_radiusAccntReq)
122        runs on R3Comp system R3System {
123        f_sample();
124        f_sample1(p_radiusAccntReq);
125        f_sample2(p_radiusAccntReq,p_radiusAccntRsp)
126}
127
128//test case skeleton without parameters, with a runs on clause
129testcase tc_sample ()
130        runs on R3Comp {
131}
132
133        //template with a single parameter
134        template type1 template1 (integer i) :={
135                int1 :=i,
136                int2 :=2
137        }
138
139        template type1 template11 (integer i) modifies template1 :={
140                int1 :=i,
141                int2 :=4
142        }
143
144
145
146        //template with multiple parameters
147        template type1 template2 (integer i1, integer i2) :={
148                int1 :=i1,
149                int2 :=i2
150        }
151
152       
153        signature s_lookup () return charstring exception (e_NotFound);
154
155        signature s_accept () return charstring exception (e_NotFound);
156
157       
158        signature s_lookup1 (in charstring key) return charstring exception (e_NotFound);
159       
160        signature s_lookup2 (in charstring key, in charstring id) return charstring exception (e_NotFound);
161       
162        signature s_lookup3 (in charstring key, in charstring id, inout integer state) return charstring exception (e_NotFound);
163       
164        //not clear if legal, or useful...
165        //parser seems to fail
166        //it is legal
167        type record type2 (integer i1, integer i2) {
168                integer range (i1 .. i2)
169        }
170
171        type integer range2 (1 .. 10);
172
173        //this should also be legal although maybe not in the current version
174        //the above is an indirect version
175        //type integer intRange (integer min, integer max ) (min .. max);
176        const type2(1,10) c_range := 3;
177       
178        //type integer binary (0,1);
179        //type integer octary (0 .. 7);
180
181        //illegal
182        //type record type3 (integer i1, integer i2) {
183        //      i1 binary,
184        //      i2 octary
185        //}
186       
187        testcase tc_sample_procedurebased() runs on sampleComponent system systemComponent{
188                port1.call(s_lookup:{x}) {
189                        []port1.getreply(s_accept:{y}) {
190                       
191                        }
192                }
193        }
194       
195        control{
196                execute(tc_sample1(template_sample1));
197                execute(tc_sample2(template_sample1,template_sample2));
198                execute(tc_sample());
199        }
200       
201}
Note: See TracBrowser for help on using the repository browser.