Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2014 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 | module TintOper | |
9 | {const integer TintOper_const1:=2; | |
10 | type component intOper_comptype { }; | |
11 | ||
12 | type port PCOType message | |
13 | { | |
14 | inout integer | |
15 | inout eint1 | |
16 | inout rint1 | |
17 | } | |
18 | ||
19 | type component bigIntOper_comptype { port PCOType comp_port } | |
20 | ||
21 | template integer tint1 := -12345678910111213141516 | |
22 | template integer tint2 := 123456789101112131415 | |
23 | template integer tint3 := -11111111111111111111111 | |
24 | template integer tint4 := 111111111111111111111 | |
25 | type enumerated eint1 {ec1(-1), ec2(2147483647), ec3(-2147483647)} | |
26 | type record rint1 { | |
27 | integer f1, | |
28 | integer f2, | |
29 | integer f3, | |
30 | integer f4 | |
31 | } | |
32 | ||
33 | template integer t_param1(rint1 par) := par.f2; // parameterised template | |
34 | ||
35 | modulepar integer par_unbound; | |
36 | modulepar integer par_bound := 42; | |
37 | ||
38 | testcase intAssign() runs on intOper_comptype | |
39 | { var integer x1:=123; | |
40 | var integer x4:=x1; | |
41 | var integer x2,x3; | |
42 | x2:=124; | |
43 | x3:=x2; | |
44 | if (x1==123) {setverdict(pass);} //at declaration, value | |
45 | else {setverdict(fail);} | |
46 | if (x4==123) {setverdict(pass);} //at declaration, variable | |
47 | else {setverdict(fail);} | |
48 | if (x2==124) {setverdict(pass);} //later, value | |
49 | else {setverdict(fail);} | |
50 | if (x3==124) {setverdict(pass);} //later, variable | |
51 | else {setverdict(fail);} | |
52 | } | |
53 | ||
54 | testcase intConst() runs on intOper_comptype { | |
55 | const integer TintOper_const3:=5; | |
56 | if (TintOper_const1==2) {setverdict(pass);} //definition part | |
57 | else {setverdict(fail);} | |
58 | //if (TintOper_const2==2) {setverdict(pass);} //control part | |
59 | // else {setverdict(fail);} | |
60 | if (TintOper_const3==5) {setverdict(pass);} //testcase | |
61 | else {setverdict(fail);} | |
62 | } | |
63 | ||
64 | testcase intCompEq() runs on intOper_comptype | |
65 | { var integer x1,x2,x3; | |
66 | x1:=100; | |
67 | x2:=100; | |
68 | x3:=200; | |
69 | if (x1==x2) {setverdict(pass);} //variable_variable | |
70 | else {setverdict(fail);} | |
71 | if (not(x3==x2)) {setverdict(pass);} //variable_variable | |
72 | else {setverdict(fail);} | |
73 | if (x1==100) {setverdict(pass);} //variable_value | |
74 | else {setverdict(fail);} | |
75 | if (not(x1==1010)) {setverdict(pass);} //variable_value | |
76 | else {setverdict(fail);} | |
77 | if (100==x1) {setverdict(pass);} //value_variable | |
78 | else {setverdict(fail);} | |
79 | if (not(1001==x1)) {setverdict(pass);} //value_variable | |
80 | else {setverdict(fail);} | |
81 | if (100==100) {setverdict(pass);} //value_value | |
82 | else {setverdict(fail);} | |
83 | if (not(1100==100)) {setverdict(pass);} //value_value | |
84 | else {setverdict(fail);} | |
85 | } | |
86 | ||
87 | testcase intCompNotEq() runs on intOper_comptype | |
88 | { var integer x1,x2,x3; | |
89 | x1:=100; | |
90 | x2:=200; | |
91 | x3:=100; | |
92 | if (x1!=x2) {setverdict(pass);} //variable_variable | |
93 | else {setverdict(fail);} | |
94 | if (not(x1!=x3)) {setverdict(pass);} //variable_variable | |
95 | else {setverdict(fail);} | |
96 | if (x1!=150) {setverdict(pass);} //variable_value | |
97 | else {setverdict(fail);} | |
98 | if (not(x1!=100)) {setverdict(pass);} //variable_value | |
99 | else {setverdict(fail);} | |
100 | if (120!=x2) {setverdict(pass);} //value_variable | |
101 | else {setverdict(fail);} | |
102 | if (not(200!=x2)) {setverdict(pass);} //value_variable | |
103 | else {setverdict(fail);} | |
104 | if (111!=112) {setverdict(pass);} //value_value | |
105 | else {setverdict(fail);} | |
106 | if (not(111!=111)) {setverdict(pass);} //value_value | |
107 | else {setverdict(fail);} | |
108 | } | |
109 | ||
110 | testcase intCompLess() runs on intOper_comptype | |
111 | { var integer x1,x2,x3; | |
112 | x1:=100; | |
113 | x2:=100; | |
114 | x3:=200; | |
115 | if (x1<x3) {setverdict(pass);} //variable_variable | |
116 | else {setverdict(fail);} | |
117 | if (not(x1<x2)) {setverdict(pass);} //variable_variable | |
118 | else {setverdict(fail);} | |
119 | if (not(x3<x1)) {setverdict(pass);} //variable_variable | |
120 | else {setverdict(fail);} | |
121 | if (x1<110) {setverdict(pass);} //variable_value | |
122 | else {setverdict(fail);} | |
123 | if (not(x1<100)) {setverdict(pass);} //variable_value | |
124 | else {setverdict(fail);} | |
125 | if (not(x2<90)) {setverdict(pass);} //variable_value | |
126 | else {setverdict(fail);} | |
127 | if (100<x3) {setverdict(pass);} //value_variable | |
128 | else {setverdict(fail);} | |
129 | if (not(100<x2)) {setverdict(pass);} //value_variable | |
130 | else {setverdict(fail);} | |
131 | if (not(110<x1)) {setverdict(pass);} //value_variable | |
132 | else {setverdict(fail);} | |
133 | if (100<120) {setverdict(pass);} //value_value | |
134 | else {setverdict(fail);} | |
135 | if (not(100<100)) {setverdict(pass);} //value_value | |
136 | else {setverdict(fail);} | |
137 | if (not(110<10)) {setverdict(pass);} //value_value | |
138 | else {setverdict(fail);} | |
139 | } | |
140 | ||
141 | testcase intCompLessEq() runs on intOper_comptype | |
142 | { var integer x1,x2,x3; | |
143 | x1:=100; | |
144 | x2:=100; | |
145 | x3:=200; | |
146 | if (x1<=x3) {setverdict(pass);} //variable_variable | |
147 | else {setverdict(fail);} | |
148 | if (x1<=x2) {setverdict(pass);} //variable_variable | |
149 | else {setverdict(fail);} | |
150 | if (not(x3<=x1)) {setverdict(pass);} //variable_variable | |
151 | else {setverdict(fail);} | |
152 | if (x1<=110) {setverdict(pass);} //variable_value | |
153 | else {setverdict(fail);} | |
154 | if (x1<=100) {setverdict(pass);} //variable_value | |
155 | else {setverdict(fail);} | |
156 | if (not(x2<=90)) {setverdict(pass);} //variable_value | |
157 | else {setverdict(fail);} | |
158 | if (100<=x3) {setverdict(pass);} //value_variable | |
159 | else {setverdict(fail);} | |
160 | if (100<=x2) {setverdict(pass);} //value_variable | |
161 | else {setverdict(fail);} | |
162 | if (not(110<=x1)) {setverdict(pass);} //value_variable | |
163 | else {setverdict(fail);} | |
164 | if (100<=120) {setverdict(pass);} //value_value | |
165 | else {setverdict(fail);} | |
166 | if (100<=100) {setverdict(pass);} //value_value | |
167 | else {setverdict(fail);} | |
168 | if (not(110<=10)) {setverdict(pass);} //value_value | |
169 | else {setverdict(fail);} | |
170 | } | |
171 | ||
172 | testcase intCompGreat() runs on intOper_comptype | |
173 | { var integer x1,x2,x3; | |
174 | x1:=100; | |
175 | x2:=100; | |
176 | x3:=200; | |
177 | if (x3>x1) {setverdict(pass);} //variable_variable | |
178 | else {setverdict(fail);} | |
179 | if (not(x1>x2)) {setverdict(pass);} //variable_variable | |
180 | else {setverdict(fail);} | |
181 | if (not(x1>x3)) {setverdict(pass);} //variable_variable | |
182 | else {setverdict(fail);} | |
183 | if (x1>99) {setverdict(pass);} //variable_value | |
184 | else {setverdict(fail);} | |
185 | if (not(x1>100)) {setverdict(pass);} //variable_value | |
186 | else {setverdict(fail);} | |
187 | if (not(x2>110)) {setverdict(pass);} //variable_value | |
188 | else {setverdict(fail);} | |
189 | if (210>x3) {setverdict(pass);} //value_variable | |
190 | else {setverdict(fail);} | |
191 | if (not(100>x2)) {setverdict(pass);} //value_variable | |
192 | else {setverdict(fail);} | |
193 | if (not(90>x1)) {setverdict(pass);} //value_variable | |
194 | else {setverdict(fail);} | |
195 | if (130>120) {setverdict(pass);} //value_value | |
196 | else {setverdict(fail);} | |
197 | if (not(100>100)) {setverdict(pass);} //value_value | |
198 | else {setverdict(fail);} | |
199 | if (not(10>110)) {setverdict(pass);} //value_value | |
200 | else {setverdict(fail);} | |
201 | } | |
202 | ||
203 | testcase intCompGreatEq() runs on intOper_comptype | |
204 | { var integer x1,x2,x3; | |
205 | x1:=100; | |
206 | x2:=100; | |
207 | x3:=200; | |
208 | if (x3>=x1) {setverdict(pass);} //variable_variable | |
209 | else {setverdict(fail);} | |
210 | if (x1>=x2) {setverdict(pass);} //variable_variable | |
211 | else {setverdict(fail);} | |
212 | if (not(x1>=x3)) {setverdict(pass);} //variable_variable | |
213 | else {setverdict(fail);} | |
214 | if (x1>=99) {setverdict(pass);} //variable_value | |
215 | else {setverdict(fail);} | |
216 | if (x1>=100) {setverdict(pass);} //variable_value | |
217 | else {setverdict(fail);} | |
218 | if (not(x2>=110)) {setverdict(pass);} //variable_value | |
219 | else {setverdict(fail);} | |
220 | if (210>=x3) {setverdict(pass);} //value_variable | |
221 | else {setverdict(fail);} | |
222 | if (100>=x2) {setverdict(pass);} //value_variable | |
223 | else {setverdict(fail);} | |
224 | if (not(90>=x1)) {setverdict(pass);} //value_variable | |
225 | else {setverdict(fail);} | |
226 | if (130>=120) {setverdict(pass);} //value_value | |
227 | else {setverdict(fail);} | |
228 | if (100>=100) {setverdict(pass);} //value_value | |
229 | else {setverdict(fail);} | |
230 | if (not(10>=110)) {setverdict(pass);} //value_value | |
231 | else {setverdict(fail);} | |
232 | } | |
233 | ||
234 | testcase intAdd() runs on intOper_comptype | |
235 | { var integer x1,x2,x3,x4,x5,x6,x7,x8,x9; | |
236 | const integer x10:=-100,x11:=-200,x12:=x10+x11; | |
237 | x1:=125; | |
238 | x2:=1000; | |
239 | x3:=x1+x2; | |
240 | x4:=x2+456; | |
241 | x5:=100+x1; | |
242 | x6:=100+234; | |
243 | x7:=-100; | |
244 | x8:=-200; | |
245 | x9:=x7+x8; | |
246 | if (x3==1125) {setverdict(pass);} //variable_variable | |
247 | else {setverdict(fail);} | |
248 | if (x4==1456) {setverdict(pass);} //variable_value | |
249 | else {setverdict(fail);} | |
250 | if (x5==225) {setverdict(pass);} //value_variable | |
251 | else {setverdict(fail);} | |
252 | if (x6==334) {setverdict(pass);} //value_value | |
253 | else {setverdict(fail);} | |
254 | if (x9==-300) {setverdict(pass);} | |
255 | else {setverdict(fail);} | |
256 | if (x7+x8==-300) {setverdict(pass);} | |
257 | else {setverdict(fail);} | |
258 | if (-100+-200==-300) {setverdict(pass);} | |
259 | else {setverdict(fail);} | |
260 | if (x12==-300) {setverdict(pass);} | |
261 | else {setverdict(fail);} | |
262 | if (x10+x11==x12) {setverdict(pass);} | |
263 | else {setverdict(fail);} | |
264 | if (-100+-200==x12) {setverdict(pass);} | |
265 | else {setverdict(fail);} | |
266 | } | |
267 | ||
268 | testcase intSubs() runs on intOper_comptype | |
269 | { var integer x1,x2,x3,x4,x5,x6; | |
270 | x1:=125; | |
271 | x2:=1125; | |
272 | x3:=x1-x2; | |
273 | x4:=x2-102; | |
274 | x5:=100-x1; | |
275 | x6:=100-234; | |
276 | if (x3==-1000) {setverdict(pass);} //variable_variable | |
277 | else {setverdict(fail);} | |
278 | if (x4==1023) {setverdict(pass);} //variable_value | |
279 | else {setverdict(fail);} | |
280 | if (x5==-25) {setverdict(pass);} //value_variable | |
281 | else {setverdict(fail);} | |
282 | if (x6==-134) {setverdict(pass);} //value_value | |
283 | else {setverdict(fail);} | |
284 | } | |
285 | ||
286 | testcase intMultipl() runs on intOper_comptype | |
287 | { var integer x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17; | |
288 | x1:=12; | |
289 | x2:=10; | |
290 | x3:=x1*x2; | |
291 | x4:=x2*-2; | |
292 | x5:=10*x1; | |
293 | x6:=-2*3; | |
294 | x7:=3*-2; | |
295 | x8:=-2*-3; | |
296 | x9:=-x1*x2; | |
297 | x10:=-x1*-x2; | |
298 | x11:=x1*-x2; | |
299 | x12:=1000000; | |
300 | x13:=x12*x2; | |
301 | x14:=-x2*x12; | |
302 | x15:=-x12*-x2; | |
303 | x16:=1000000*10; | |
304 | x17:=-10*1000000; | |
305 | if (x3==120) {setverdict(pass);} //variable_variable | |
306 | else {setverdict(fail);} | |
307 | if (x4==-20) {setverdict(pass);} //variable_value | |
308 | else {setverdict(fail);} | |
309 | if (x5==120) {setverdict(pass);} //value_variable | |
310 | else {setverdict(fail);} | |
311 | if (x6==-6) {setverdict(pass);} //value_value | |
312 | else {setverdict(fail);} | |
313 | if (x7==-6) {setverdict(pass);} | |
314 | else {setverdict(fail);} | |
315 | if (x8==6) {setverdict(pass);} | |
316 | else {setverdict(fail);} | |
317 | if (x9==-120) {setverdict(pass);} | |
318 | else {setverdict(fail);} | |
319 | if (x10==120) {setverdict(pass);} | |
320 | else {setverdict(fail);} | |
321 | if (x11==-120) {setverdict(pass);} | |
322 | else {setverdict(fail);} | |
323 | if (x13==10000000) {setverdict(pass);} | |
324 | else {setverdict(fail);} | |
325 | if (x14==-10000000) {setverdict(pass);} | |
326 | else {setverdict(fail);} | |
327 | if (x15==10000000) {setverdict(pass);} | |
328 | else {setverdict(fail);} | |
329 | if (x16==10000000) {setverdict(pass);} | |
330 | else {setverdict(fail);} | |
331 | if (x17==-10000000) {setverdict(pass);} | |
332 | else {setverdict(fail);} | |
333 | } | |
334 | ||
335 | testcase intDiv() runs on intOper_comptype | |
336 | { var integer x1,x2,x3,x4,x5,x6,x7,x8; | |
337 | x1:=-125; | |
338 | x2:=501; | |
339 | x3:=x2/x1; | |
340 | x4:=x2/50; | |
341 | x5:=252/x1; | |
342 | x6:=102/-25; | |
343 | x7:=-102/-25; | |
344 | x8:=-25/102; | |
345 | if (x3==-4) {setverdict(pass);} //variable_variable | |
346 | else {setverdict(fail);} | |
347 | if (x4==10) {setverdict(pass);} //variable_value | |
348 | else {setverdict(fail);} | |
349 | if (x5==-2) {setverdict(pass);} //value_variable | |
350 | else {setverdict(fail);} | |
351 | if (x6==-4) {setverdict(pass);} //value_value | |
352 | else {setverdict(fail);} | |
353 | if (x7==4) {setverdict(pass);} | |
354 | else {setverdict(fail);} | |
355 | if (x8==0) {setverdict(pass);} | |
356 | else {setverdict(fail);} | |
357 | } | |
358 | ||
359 | testcase intMod() runs on intOper_comptype | |
360 | { var integer x1,x2,x3,x4,x5,x6; | |
361 | x1:=-125; | |
362 | x2:=503; | |
363 | x3:=x2 mod x1; | |
364 | x4:=x2 mod 50; | |
365 | x5:=254 mod x1; | |
366 | x6:=102 mod -25; // positive x | |
367 | if (x3==3) {setverdict(pass);} //variable_variable | |
368 | else {setverdict(fail);} | |
369 | if (x4==3) {setverdict(pass);} //variable_value | |
370 | else {setverdict(fail);} | |
371 | if (x5==4) {setverdict(pass);} //value_variable | |
372 | else {setverdict(fail);} | |
373 | if (x6==2) {setverdict(pass);} //value_value | |
374 | else {setverdict(fail);} | |
375 | x2:=-503; | |
376 | x3:=x2 mod x1; | |
377 | x4:=x2 mod 50; | |
378 | x5:=-254 mod x1; | |
379 | x6:=-102 mod -25; // negative x | |
380 | if (x3==122) {setverdict(pass);} //variable_variable | |
381 | else {setverdict(fail);} | |
382 | if (x4==47) {setverdict(pass);} //variable_value | |
383 | else {setverdict(fail);} | |
384 | if (x5==121) {setverdict(pass);} //value_variable | |
385 | else {setverdict(fail);} | |
386 | if (x6==23) {setverdict(pass);} //value_value | |
387 | else {setverdict(fail);} | |
388 | } | |
389 | ||
390 | testcase intRem() runs on intOper_comptype | |
391 | { var integer x1,x2,x3,x4,x5,x6; | |
392 | x1:=-125; | |
393 | x2:=503; | |
394 | x3:=x2 rem x1; | |
395 | x4:=x2 rem 50; | |
396 | x5:=254 rem x1; | |
397 | x6:=102 rem -25; // positive x | |
398 | if (x3==3) {setverdict(pass);} //variable_variable | |
399 | else {setverdict(fail);} | |
400 | if (x4==3) {setverdict(pass);} //variable_value | |
401 | else {setverdict(fail);} | |
402 | if (x5==4) {setverdict(pass);} //value_variable | |
403 | else {setverdict(fail);} | |
404 | if (x6==2) {setverdict(pass);} //value_value | |
405 | else {setverdict(fail);} | |
406 | x2:=-503; | |
407 | x3:=x2 rem x1; | |
408 | x4:=x2 rem 50; | |
409 | x5:=-254 rem x1; | |
410 | x6:=-102 rem -25; // negative x | |
411 | if (x3==-3) {setverdict(pass);} //variable_variable | |
412 | else {setverdict(fail);} | |
413 | if (x4==-3) {setverdict(pass);} //variable_value | |
414 | else {setverdict(fail);} | |
415 | if (x5==-4) {setverdict(pass);} //value_variable | |
416 | else {setverdict(fail);} | |
417 | if (x6==-2) {setverdict(pass);} //value_value | |
418 | else {setverdict(fail);} | |
419 | } | |
420 | ||
421 | /* | |
422 | testcase intShiftRight1() runs on intOper_comptype | |
423 | { var integer x1,x2; | |
424 | x1:=234; | |
425 | x2:=x1 >> 1; | |
426 | if (x2==117) {setverdict(pass);} //variable | |
427 | else {setverdict(fail);} | |
428 | } | |
429 | ||
430 | testcase intShiftRight2() runs on intOper_comptype | |
431 | { var integer x1,x2; | |
432 | x1:=234; | |
433 | x2:=x1 >> 2; | |
434 | if (x2==58) {setverdict(pass);} | |
435 | else {setverdict(fail);} | |
436 | } | |
437 | ||
438 | testcase intShiftRightSum() runs on intOper_comptype | |
439 | { var integer x1,x2; | |
440 | x1:=234; | |
441 | x2:=x1 >> (1+1); | |
442 | if (x2==58) {setverdict(pass);} | |
443 | else {setverdict(fail);} | |
444 | } | |
445 | ||
446 | testcase intShiftLeft1() runs on intOper_comptype | |
447 | { var integer x1,x2; | |
448 | x1:=112; | |
449 | x2:=x1 << 1; | |
450 | if (x2==224) {setverdict(pass);} | |
451 | else {setverdict(fail);} | |
452 | } | |
453 | ||
454 | testcase intShiftLeft2() runs on intOper_comptype | |
455 | { var integer x1,x2; | |
456 | x1:=112; | |
457 | x2:=x1 << 2; | |
458 | if (x2==448) {setverdict(pass);} | |
459 | else {setverdict(fail);} | |
460 | } | |
461 | ||
462 | testcase intShiftLeftSum() runs on intOper_comptype | |
463 | { var integer x1,x2; | |
464 | x1:=112; | |
465 | x2:=x1 << (1+1); | |
466 | if (x2==448) {setverdict(pass);} | |
467 | else {setverdict(fail);} | |
468 | } | |
469 | */ | |
470 | ||
471 | testcase bigIntConst() runs on bigIntOper_comptype | |
472 | { | |
473 | connect(self:comp_port, self:comp_port) | |
474 | timer T := 1.0 | |
475 | comp_port.send(-12345678910111213141516) | |
476 | comp_port.send(123456789101112131415) | |
477 | comp_port.send(-1234567891011121314) | |
478 | comp_port.send(12345678910111213) | |
479 | T.start | |
480 | alt { | |
481 | [11111111111111111111 > 0] comp_port.receive(-12345678910111213141516) { setverdict(pass) repeat } | |
482 | [22222222222222222222 > 11111111111111111111] comp_port.receive(123456789101112131415) { setverdict(pass) repeat } | |
483 | [33333333333333333333 > 22222222222222222222] comp_port.receive(-1234567891011121314) { setverdict(pass) repeat } | |
484 | [44444444444444444444 > 33333333333333333333] comp_port.receive(12345678910111213) { setverdict(pass) } | |
485 | [] T.timeout { setverdict(fail) } | |
486 | } | |
487 | disconnect(self:comp_port, self:comp_port) | |
488 | } | |
489 | ||
490 | testcase bigIntVar() runs on bigIntOper_comptype | |
491 | { | |
492 | connect(self:comp_port, self:comp_port) | |
493 | timer T := 1.0 | |
494 | const integer ca := 0 | |
495 | const integer cb := 11111111111111111111 | |
496 | const integer cc := 22222222222222222222 | |
497 | const integer cd := 33333333333333333333 | |
498 | const integer ce := 44444444444444444444 | |
499 | var integer a := -12345678910111213141516 | |
500 | var integer b := 123456789101112131415 | |
501 | var integer c := -1234567891011121314 | |
502 | var integer d := 123456789101112131 | |
503 | comp_port.send(a) | |
504 | comp_port.send(b) | |
505 | comp_port.send(c) | |
506 | comp_port.send(d) | |
507 | T.start | |
508 | alt { | |
509 | [cb > ca] comp_port.receive(a) { setverdict(pass) repeat } | |
510 | [cc > cb] comp_port.receive(b) { setverdict(pass) repeat } | |
511 | [cd > cc] comp_port.receive(c) { setverdict(pass) repeat } | |
512 | [ce > cd] comp_port.receive(d) { setverdict(pass) } | |
513 | [] T.timeout { setverdict(fail) } | |
514 | } | |
515 | disconnect(self:comp_port, self:comp_port) | |
516 | } | |
517 | ||
518 | testcase bigIntTemplate() runs on bigIntOper_comptype | |
519 | { | |
520 | connect(self:comp_port, self:comp_port) | |
521 | timer T := 1.0 | |
522 | var integer a := -12345678910111213141516 | |
523 | var integer b := 123456789101112131415 | |
524 | var integer c := -11111111111111111111111 | |
525 | var integer d := 111111111111111111111 | |
526 | // No `valueof' on large integer templates. Only values can be sent on | |
527 | // ports due to interface problems. | |
528 | comp_port.send(a) | |
529 | comp_port.send(b) | |
530 | comp_port.send(c) | |
531 | comp_port.send(d) | |
532 | T.start | |
533 | alt { | |
534 | [] comp_port.receive(tint1) { setverdict(pass) repeat } | |
535 | [] comp_port.receive(tint2) { setverdict(pass) repeat } | |
536 | [] comp_port.receive(tint3) { setverdict(pass) repeat } | |
537 | [] comp_port.receive(tint4) { setverdict(pass) } | |
538 | [] T.timeout { setverdict(fail) } | |
539 | } | |
540 | disconnect(self:comp_port, self:comp_port) | |
541 | } | |
542 | ||
543 | testcase bigIntVariableTemplate() runs on bigIntOper_comptype | |
544 | { | |
545 | connect(self:comp_port, self:comp_port) | |
546 | timer T := 1.0 | |
547 | var integer a := -12345678910111213141516 | |
548 | var integer b := 123456789101112131415 | |
549 | var integer c := -11111111111111111111111 | |
550 | var integer d := 111111111111111111111 | |
551 | var template integer vtint1 := a | |
552 | var template integer vtint2 := b | |
553 | var template integer vtint3 := -11111111111111111111111 | |
554 | var template integer vtint4 := 111111111111111111111 | |
555 | comp_port.send(a) | |
556 | comp_port.send(b) | |
557 | comp_port.send(c) | |
558 | comp_port.send(d) | |
559 | T.start | |
560 | alt { | |
561 | [] comp_port.receive(vtint1) { setverdict(pass) repeat } | |
562 | [] comp_port.receive(vtint2) { setverdict(pass) repeat } | |
563 | [] comp_port.receive(vtint3) { setverdict(pass) repeat } | |
564 | [] comp_port.receive(vtint4) { setverdict(pass) } | |
565 | [] T.timeout { setverdict(fail) } | |
566 | } | |
567 | disconnect(self:comp_port, self:comp_port) | |
568 | } | |
569 | ||
570 | testcase bigIntEnumerated() runs on bigIntOper_comptype | |
571 | { | |
572 | connect(self:comp_port, self:comp_port) | |
573 | timer T := 1.0 | |
574 | var eint1 veint1 := ec1 | |
575 | var eint1 veint2 := ec2 | |
576 | var eint1 veint3 := ec3 | |
577 | comp_port.send(veint1); T.start; comp_port.receive(veint1) { setverdict(pass) }; T.stop | |
578 | comp_port.send(veint2); T.start; comp_port.receive(veint2) { setverdict(pass) }; T.stop | |
579 | comp_port.send(veint3); T.start; comp_port.receive(veint3) { setverdict(pass) }; T.stop | |
580 | disconnect(self:comp_port, self:comp_port) | |
581 | } | |
582 | ||
583 | testcase bigIntRecord() runs on bigIntOper_comptype | |
584 | { | |
585 | connect(self:comp_port, self:comp_port) | |
586 | timer T := 1.0 | |
587 | var rint1 vrint1 := { 12345678910111213141516, -11111111111111111111, 1234, -12345 } | |
588 | var rint1 vrint2 := { 128, 65536, 4294967296, -4294967296 } | |
589 | var rint1 vrint3 := { 2147483648, -2147483648, 0, -1 } | |
590 | var rint1 vrint4 := { 4294967296, -4294967296, 4294967295, -4294967295 } | |
591 | var rint1 vrint5 := { 4294967297, -4294967297, 2147483648, -2147483648 } | |
592 | var rint1 vrint6 := { 2147483647, -2147483647, 2147483649, -2147483649 } | |
593 | var rint1 vrint7 := { 260217910, -260217910, 1, -1 } | |
594 | comp_port.send(vrint1); T.start; comp_port.receive(vrint1) { setverdict(pass) }; T.stop | |
595 | comp_port.send(vrint2); T.start; comp_port.receive(vrint2) { setverdict(pass) }; T.stop | |
596 | comp_port.send(vrint3); T.start; comp_port.receive(vrint3) { setverdict(pass) }; T.stop | |
597 | comp_port.send(vrint4); T.start; comp_port.receive(vrint4) { setverdict(pass) }; T.stop | |
598 | comp_port.send(vrint5); T.start; comp_port.receive(vrint5) { setverdict(pass) }; T.stop | |
599 | comp_port.send(vrint6); T.start; comp_port.receive(vrint6) { setverdict(pass) }; T.stop | |
600 | comp_port.send(vrint7); T.start; comp_port.receive(vrint7) { setverdict(pass) }; T.stop | |
601 | disconnect(self:comp_port, self:comp_port) | |
602 | } | |
603 | ||
604 | testcase bigIntLogicalOps() runs on bigIntOper_comptype | |
605 | { | |
606 | { | |
607 | // Only Cond2/Cond4/Cond6/Cond7/Cond10/Cond11/Cond15/Cond17/Cond18 should | |
608 | // stay. Test for conditional operators and CP on big integers. | |
609 | if (12345678910111213141516 < 0) { log("Cond1"); setverdict(fail) } // Removed by CP. | |
610 | if (12345678910111213141516 > 0) { log("Cond2"); setverdict(pass) } | |
611 | if (12345678910111213141516 == 0) { log("Cond3"); setverdict(fail) } // Removed by CP. | |
612 | if (12345678910111213141516 != 0) { log("Cond4"); setverdict(pass) } | |
613 | if (12345678910111213141516 <= 0) { log("Cond5"); setverdict(fail) } // Removed by CP. | |
614 | if (12345678910111213141516 >= 0) { log("Cond6"); setverdict(pass) } | |
615 | if (0 < 12345678910111213141516) { log("Cond7"); setverdict(pass) } | |
616 | if (0 > 12345678910111213141516) { log("Cond8"); setverdict(fail) } // Removed by CP. | |
617 | if (0 == 12345678910111213141516) { log("Cond9"); setverdict(fail) } // Removed by CP. | |
618 | if (0 != 12345678910111213141516) { log("Cond10"); setverdict(pass) } | |
619 | if (0 <= 12345678910111213141516) { log("Cond11"); setverdict(pass) } | |
620 | if (0 >= 12345678910111213141516) { log("Cond12"); setverdict(fail) } // Removed by CP. | |
621 | if (12345678910111213141516 < 12345678910111213141516) { log("Cond13"); setverdict(fail) } // Removed by CP. | |
622 | if (12345678910111213141516 > 12345678910111213141516) { log("Cond14"); setverdict(fail) } // Removed by CP. | |
623 | if (12345678910111213141516 == 12345678910111213141516) { log("Cond15"); setverdict(pass) } | |
624 | if (12345678910111213141516 != 12345678910111213141516) { log("Cond16"); setverdict(fail) } // Removed by CP. | |
625 | if (12345678910111213141516 <= 12345678910111213141516) { log("Cond17"); setverdict(pass) } | |
626 | if (12345678910111213141516 >= 12345678910111213141516) { log("Cond18"); setverdict(pass) } | |
627 | } | |
628 | { | |
629 | // With a constant. Same as the previous. | |
630 | const integer i := 0, j := 12345678910111213141516 | |
631 | if (j < i) { log("Cond19"); setverdict(fail) } // Removed by CP. | |
632 | if (j > i) { log("Cond20"); setverdict(pass) } | |
633 | if (j == i) { log("Cond21"); setverdict(fail) } // Removed by CP. | |
634 | if (j != i) { log("Cond22"); setverdict(pass) } | |
635 | if (j <= i) { log("Cond23"); setverdict(fail) } // Removed by CP. | |
636 | if (j >= i) { log("Cond24"); setverdict(pass) } | |
637 | if (i < j) { log("Cond25"); setverdict(pass) } | |
638 | if (i > j) { log("Cond26"); setverdict(fail) } // Removed by CP. | |
639 | if (i == j) { log("Cond27"); setverdict(fail) } // Removed by CP. | |
640 | if (i != j) { log("Cond28"); setverdict(pass) } | |
641 | if (i <= j) { log("Cond29"); setverdict(pass) } | |
642 | if (i >= j) { log("Cond30"); setverdict(fail) } // Removed by CP. | |
643 | if (j < j) { log("Cond31"); setverdict(fail) } // Removed by CP. | |
644 | if (j > j) { log("Cond32"); setverdict(fail) } // Removed by CP. | |
645 | if (j == j) { log("Cond33"); setverdict(pass) } | |
646 | if (j != j) { log("Cond34"); setverdict(fail) } // Removed by CP. | |
647 | if (j <= j) { log("Cond35"); setverdict(pass) } | |
648 | if (j >= j) { log("Cond36"); setverdict(pass) } | |
649 | } | |
650 | { | |
651 | // With variable operands. No CP. | |
652 | var integer i := 0, j := 12345678910111213141516, result := 0 | |
653 | if (12345678910111213141516 < i) { log("Cond37"); result := result + 1 } | |
654 | if (12345678910111213141516 > i) { log("Cond38"); result := result + 1 } | |
655 | if (12345678910111213141516 == i) { log("Cond39"); result := result + 1 } | |
656 | if (12345678910111213141516 != i) { log("Cond40"); result := result + 1 } | |
657 | if (12345678910111213141516 <= i) { log("Cond41"); result := result + 1 } | |
658 | if (12345678910111213141516 >= i) { log("Cond42"); result := result + 1 } | |
659 | if (i < 12345678910111213141516) { log("Cond43"); result := result + 1 } | |
660 | if (i > 12345678910111213141516) { log("Cond44"); result := result + 1 } | |
661 | if (i == 12345678910111213141516) { log("Cond45"); result := result + 1 } | |
662 | if (i != 12345678910111213141516) { log("Cond46"); result := result + 1 } | |
663 | if (i <= 12345678910111213141516) { log("Cond47"); result := result + 1 } | |
664 | if (i >= 12345678910111213141516) { log("Cond48"); result := result + 1 } | |
665 | if (12345678910111213141516 < j) { log("Cond49"); result := result + 1 } | |
666 | if (j > 12345678910111213141516) { log("Cond50"); result := result + 1 } | |
667 | if (12345678910111213141516 == j) { log("Cond51"); result := result + 1 } | |
668 | if (j != 12345678910111213141516) { log("Cond52"); result := result + 1 } | |
669 | if (12345678910111213141516 <= j) { log("Cond53"); result := result + 1 } | |
670 | if (j >= 12345678910111213141516) { log("Cond54"); result := result + 1 } | |
671 | if (result == 9) { setverdict(pass) } // Number of branches executed. | |
672 | else { setverdict(fail) } | |
673 | } | |
674 | } | |
675 | ||
676 | testcase bigIntBasicArithmetic() runs on bigIntOper_comptype | |
677 | { | |
678 | { | |
679 | // Basic tests for add/subtract/multiply/divide/mod/rem. Constant literals | |
680 | // at first. These are all handled by CP. | |
681 | if (100000000000000000000 + 100000000000000000000 == 200000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
682 | if (100000000000000000000 + 0 == 100000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
683 | if (0 + 100000000000000000000 == 100000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
684 | if (100000000000000000000 - 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } | |
685 | if (100000000000000000000 - 0 == 100000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
686 | if (0 - 100000000000000000000 == -100000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
687 | if (100000000000000000000 * 100000000000000000000 == 10000000000000000000000000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
688 | if (-100000000000000000000 * 100000000000000000000 == -10000000000000000000000000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
689 | if (-100000000000000000000 * -100000000000000000000 == 10000000000000000000000000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
690 | if (100000000000000000000 * 0 == 0) { setverdict(pass) } else { setverdict(fail) } | |
691 | if (0 * 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } | |
692 | if (100000000000000000000 / 100000000000000000000 == 1) { setverdict(pass) } else { setverdict(fail) } | |
693 | if (0 / 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } | |
694 | if (100000000000000000000 mod 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } // Same as rem. | |
695 | if (0 mod 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } | |
696 | if (100000000000000000000 rem 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } | |
697 | if (0 rem 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } | |
698 | } | |
699 | { | |
700 | // Same as before with constants. | |
701 | const integer i := 0, j := 100000000000000000000, k := 1 | |
702 | if (j + j == 200000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
703 | if (j + i == j) { setverdict(pass) } else { setverdict(fail) } | |
704 | if (i + j == j) { setverdict(pass) } else { setverdict(fail) } | |
705 | if (j - j == i) { setverdict(pass) } else { setverdict(fail) } | |
706 | if (j - i == j) { setverdict(pass) } else { setverdict(fail) } | |
707 | if (i - j == -j) { setverdict(pass) } else { setverdict(fail) } | |
708 | if (j * j == 10000000000000000000000000000000000000000) { setverdict(pass) } else { setverdict(fail) } // Ugly. | |
709 | if (j * i == i) { setverdict(pass) } else { setverdict(fail) } | |
710 | if (i * j == i) { setverdict(pass) } else { setverdict(fail) } | |
711 | if (k * j == j) { setverdict(pass) } else { setverdict(fail) } | |
712 | if (k * -j == -j) { setverdict(pass) } else { setverdict(fail) } | |
713 | if (-k * j == -j) { setverdict(pass) } else { setverdict(fail) } | |
714 | if (-k * -j == j) { setverdict(pass) } else { setverdict(fail) } | |
715 | if (j / j == 1) { setverdict(pass) } else { setverdict(fail) } | |
716 | if (i / j == i) { setverdict(pass) } else { setverdict(fail) } | |
717 | if (j mod j == i) { setverdict(pass) } else { setverdict(fail) } // Same as rem. | |
718 | if (i mod j == i) { setverdict(pass) } else { setverdict(fail) } | |
719 | if (j rem j == i) { setverdict(pass) } else { setverdict(fail) } | |
720 | if (i rem j == i) { setverdict(pass) } else { setverdict(fail) } | |
721 | } | |
722 | { | |
723 | // With variables and constants mixed. No CP. | |
724 | var integer i := 0, j := 100000000000000000000, k := 1 | |
725 | if (100000000000000000000 + j == 200000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
726 | if (j + i == 100000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
727 | if (i + 100000000000000000000 == j) { setverdict(pass) } else { setverdict(fail) } | |
728 | if (100000000000000000000 - j == 0) { setverdict(pass) } else { setverdict(fail) } | |
729 | if (j - i == 100000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
730 | if (i - 100000000000000000000 == -j) { setverdict(pass) } else { setverdict(fail) } | |
731 | if (100000000000000000000 * j == 10000000000000000000000000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
732 | if (100000000000000000000 * -j == -10000000000000000000000000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
733 | if (-100000000000000000000 * j == -10000000000000000000000000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
734 | if (j * 100000000000000000000 == 10000000000000000000000000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
735 | if (-j * 100000000000000000000 == -10000000000000000000000000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
736 | if (j * -100000000000000000000 == -10000000000000000000000000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
737 | if (i * 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } | |
738 | if (j / 100000000000000000000 == k) { setverdict(pass) } else { setverdict(fail) } | |
739 | if (i / 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } | |
740 | if (j mod 100000000000000000000 == i) { setverdict(pass) } else { setverdict(fail) } // Same as rem. | |
741 | if (i mod 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } | |
742 | if (100000000000000000000 rem j == i) { setverdict(pass) } else { setverdict(fail) } | |
743 | if (i rem 100000000000000000000 == 0) { setverdict(pass) } else { setverdict(fail) } | |
744 | } | |
745 | { | |
746 | var integer i := 4294967295, j := -4294967295, k := 2147483647, l := -2147483647 | |
747 | if ((i + i) / 4294967295 == 2) { setverdict(pass) } else { setverdict(fail) } | |
748 | if ((j + j) / -4294967295 == 2) { setverdict(pass) } else { setverdict(fail) } | |
749 | if ((k + k) / 2147483647 == 2) { setverdict(pass) } else { setverdict(fail) } | |
750 | if ((l + l) / -2147483647 == 2) { setverdict(pass) } else { setverdict(fail) } | |
751 | } | |
752 | { | |
753 | var integer i := -100000000000000000000, j := -100000000000000000000, k := i + j | |
754 | const integer l := -100000000000000000000, m := -100000000000000000000, o := l + m | |
755 | if (i + j == -200000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
756 | if (k == -200000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
757 | if (-100000000000000000000 + -100000000000000000000 == k) { setverdict(pass) } else { setverdict(fail) } | |
758 | if (-100000000000000000000 + -100000000000000000000 == o) { setverdict(pass) } else { setverdict(fail) } | |
759 | if (-100000000000000000000 + -100000000000000000000 == -200000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
760 | if (l + m == -200000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
761 | if (o == -200000000000000000000) { setverdict(pass) } else { setverdict(fail) } | |
762 | } | |
763 | } | |
764 | ||
765 | template rint1 myrint1 := { f1 := 260217910, f2 := 1234567891011121314151617181920, f3 := 0, f4 := -260217910 } | |
766 | template rint1 myrint2 := { f1 := 2147483648, f2 := -2147483648, f3 := 0, f4 := -1 } | |
767 | template rint1 myrint3 := { 4294967296, -4294967296, 4294967295, -4294967295 } | |
768 | template rint1 myrint4 := { 4294967297, -4294967297, 2147483648, -2147483648 } | |
769 | ||
770 | testcase bigIntTemplateSendRecv() runs on bigIntOper_comptype | |
771 | { | |
772 | // Implicit `valueof' on sending with implicit matching. | |
773 | connect(self:comp_port, self:comp_port) | |
774 | timer T := 1.0 | |
775 | comp_port.send(myrint1); T.start; comp_port.receive(myrint1) { setverdict(pass) }; T.stop | |
776 | comp_port.send(myrint2); T.start; comp_port.receive(myrint2) { setverdict(pass) }; T.stop | |
777 | comp_port.send(myrint3); T.start; comp_port.receive(myrint3) { setverdict(pass) }; T.stop | |
778 | comp_port.send(myrint4); T.start; comp_port.receive(myrint4) { setverdict(pass) }; T.stop | |
779 | disconnect(self:comp_port, self:comp_port) | |
780 | } | |
781 | ||
782 | // For testing operator-() in compile-time/run-time on boundaries. | |
783 | testcase bigIntOnTheEdge() runs on bigIntOper_comptype | |
784 | { | |
785 | const integer LLONG_MIN := -9223372036854775808 | |
786 | const integer LLONG_MAX := 9223372036854775807 | |
787 | const integer INT_MIN := -2147483648 | |
788 | const integer INT_MAX := 2147483647 | |
789 | var integer llong_min_v := LLONG_MIN | |
790 | var integer llong_max_v := LLONG_MAX | |
791 | var integer int_min_v := INT_MIN | |
792 | var integer int_max_v := INT_MAX | |
793 | // Compile-time. | |
794 | if (-LLONG_MIN == 9223372036854775808) { setverdict(pass) } else { setverdict(fail) } | |
795 | if (-LLONG_MAX == -9223372036854775807) { setverdict(pass) } else { setverdict(fail) } | |
796 | if (-LLONG_MIN == LLONG_MAX + 1) { setverdict(pass) } else { setverdict(fail) } | |
797 | if (-LLONG_MAX == LLONG_MIN + 1) { setverdict(pass) } else { setverdict(fail) } | |
798 | if (-INT_MIN == 2147483648) { setverdict(pass) } else { setverdict(fail) } | |
799 | if (-INT_MAX == -2147483647) { setverdict(pass) } else { setverdict(fail) } | |
800 | if (-INT_MIN == INT_MAX + 1) { setverdict(pass) } else { setverdict(fail) } | |
801 | if (-INT_MAX == INT_MIN + 1) { setverdict(pass) } else { setverdict(fail) } | |
802 | if (9223372036854775808 - 1 == LLONG_MAX) { setverdict(pass) } else { setverdict(fail) } | |
803 | if (-LLONG_MIN - 1 == LLONG_MAX) { setverdict(pass) } else { setverdict(fail) } | |
804 | // Run-time. | |
805 | if (-llong_min_v == 9223372036854775808) { setverdict(pass) } else { setverdict(fail) } | |
806 | if (-llong_max_v == -9223372036854775807) { setverdict(pass) } else { setverdict(fail) } | |
807 | if (-llong_min_v == llong_max_v + 1) { setverdict(pass) } else { setverdict(fail) } | |
808 | if (-llong_max_v == llong_min_v + 1) { setverdict(pass) } else { setverdict(fail) } | |
809 | if (-int_min_v == 2147483648) { setverdict(pass) } else { setverdict(fail) } | |
810 | if (-int_max_v == -2147483647) { setverdict(pass) } else { setverdict(fail) } | |
811 | if (-int_min_v == int_max_v + 1) { setverdict(pass) } else { setverdict(fail) } | |
812 | if (-int_max_v == int_min_v + 1) { setverdict(pass) } else { setverdict(fail) } | |
813 | if (2147483648 - 1 == int_max_v) { setverdict(pass) } else { setverdict(fail) } | |
814 | if (-int_min_v - 1 == int_max_v) { setverdict(pass) } else { setverdict(fail) } | |
815 | } | |
816 | ||
817 | external function MyConverter() return boolean | |
818 | ||
819 | testcase bigIntLongLong() runs on bigIntOper_comptype | |
820 | { | |
821 | if (MyConverter()) { setverdict(pass) } else { setverdict(fail) } | |
822 | } | |
823 | ||
824 | type component intOperSubtypes_comptype { } | |
825 | ||
826 | type integer myi1 | |
827 | type integer myi2 (1, 2, 3) | |
828 | type integer myi3 (-infinity..0) | |
829 | type integer myi4 (-infinity..infinity) | |
830 | type integer myi5 (-infinity..infinity, 0, 1, 2, 3) | |
831 | type myi5 myi6 | |
832 | type integer myi7 (2147483648, 4294967296, 8589934592) | |
833 | type integer myi8 (2147483648..8589934592) | |
834 | type integer myi9 (1, 2..c_myi1 + 3) | |
835 | type integer myi10 (1, str2int(log2str(valueof(t_myi1))) + 1, 3) | |
836 | type integer myi11 (-1, -0, 1) | |
837 | type integer myi12 (myi2, myi3) | |
838 | type myi12 myi13 (myi2) | |
839 | type myi4 myi14 (0..infinity) | |
840 | ||
841 | const myi1 c_myi1 := 1 | |
842 | const myi2 c_myi2 := 1 | |
843 | const myi3 c_myi3 := 0 | |
844 | const myi4 c_myi4 := c_myi3 | |
845 | const myi5 c_myi5 := c_myi4 | |
846 | const myi6 c_myi6 := c_myi5 | |
847 | const myi7 c_myi7 := 4294967296 | |
848 | const myi8 c_myi8 := c_myi7 | |
849 | const myi9 c_myi9 := 4 | |
850 | const myi10 c_myi10 := c_myi1 | |
851 | const myi12 c_myi11 := 0 | |
852 | const myi13 c_myi12 := 1 | |
853 | template myi1 t_myi1 := 1 | |
854 | template myi2 t_myi2 := 1 | |
855 | template myi3 t_myi3 := 0 | |
856 | template myi4 t_myi4 := t_myi3 | |
857 | template myi5 t_myi5 := t_myi4 | |
858 | template myi6 t_myi6 := t_myi5 | |
859 | template myi7 t_myi7 := 4294967296 | |
860 | template myi8 t_myi8 := t_myi7 | |
861 | template myi12 t_myi9 := 0 | |
862 | template myi13 t_myi10 := 1 | |
863 | ||
864 | function f_i1() return boolean { | |
865 | var myi9 v_myi1 := 4 | |
866 | var myi10 v_myi2 := v_myi1 | |
867 | var template myi9 vt_myi1 := 4 | |
868 | var template myi10 vt_myi2 := vt_myi1 | |
869 | if (v_myi1 == valueof(vt_myi1) and valueof(vt_myi1) == c_myi1 and | |
870 | v_myi2 == valueof(vt_myi2) and valueof(vt_myi2) == c_myi2) { return true } | |
871 | else { return false } | |
872 | } | |
873 | ||
874 | testcase intSubtypes() runs on intOperSubtypes_comptype | |
875 | { | |
876 | if (c_myi1 == c_myi2 and valueof(t_myi1) == valueof(t_myi2)) { setverdict(pass) } | |
877 | else { setverdict(fail) } | |
878 | var template myi1 vt_myi1 := 1 | |
879 | var template myi2 vt_myi2 := 1 | |
880 | var myi1 v_myi1 := 1 | |
881 | var myi2 v_myi2 := 1 | |
882 | if (v_myi1 == v_myi2 and valueof(vt_myi1) == valueof(vt_myi2)) { setverdict(pass) } | |
883 | else { setverdict(fail) } | |
884 | if (c_myi3 == c_myi4 and c_myi4 == c_myi5 and c_myi5 == c_myi6 and | |
885 | valueof(t_myi3) == valueof(t_myi4) and valueof(t_myi4) == valueof(t_myi5) and | |
886 | valueof(t_myi5) == valueof(t_myi6)) { setverdict(pass) } | |
887 | else { setverdict(fail) } | |
888 | var template myi3 vt_myi3 := 0 | |
889 | var template myi4 vt_myi4 := vt_myi3 | |
890 | var template myi5 vt_myi5 := vt_myi4 | |
891 | var template myi6 vt_myi6 := vt_myi5 | |
892 | var myi3 v_myi3 := 0 | |
893 | var myi4 v_myi4 := v_myi3 | |
894 | var myi5 v_myi5 := v_myi4 | |
895 | var myi6 v_myi6 := v_myi5 | |
896 | if (v_myi3 == v_myi4 and v_myi4 == v_myi5 and v_myi5 == v_myi6 and | |
897 | valueof(vt_myi3) == valueof(vt_myi4) and valueof(vt_myi4) == valueof(vt_myi5) and | |
898 | valueof(vt_myi5) == valueof(vt_myi6)) { setverdict(pass) } | |
899 | else { setverdict(fail) } | |
900 | if (c_myi7 == c_myi8 and valueof(t_myi7) == valueof(t_myi8)) { setverdict(pass) } | |
901 | else { setverdict(fail) } | |
902 | var template myi7 vt_myi7 := 4294967296 | |
903 | var template myi8 vt_myi8 := vt_myi7 | |
904 | var myi7 v_myi7 := 4294967296 | |
905 | var myi8 v_myi8 := v_myi7 | |
906 | if (v_myi7 == v_myi8 and valueof(vt_myi7) == valueof(vt_myi8)) { setverdict(pass) } | |
907 | else { setverdict(fail) } | |
908 | } | |
909 | ||
910 | testcase intIsvalue() runs on intOper_comptype | |
911 | { | |
912 | var integer i0, i1 := 1; | |
913 | var template integer one_int := (13); | |
914 | var template integer two_ints := (1,2); | |
915 | ||
916 | if ( isvalue(i0) ) { setverdict(fail); } else { setverdict(pass); }; | |
917 | if ( isvalue(i1) ) { setverdict(pass); } else { setverdict(fail); }; | |
918 | if ( isvalue(TintOper_const1) ) { setverdict(pass); } else { setverdict(fail); }; | |
919 | if ( isvalue(one_int) ) { setverdict(pass); } else { setverdict(fail); }; | |
920 | if ( isvalue(two_ints) ) { setverdict(fail); } else { setverdict(pass); }; | |
921 | ||
922 | if ( isvalue(par_unbound) ) { setverdict(fail); } else { setverdict(pass); }; | |
923 | if ( isvalue(par_bound) ) { setverdict(pass); } else { setverdict(fail); }; | |
924 | ||
925 | if ( isvalue(i1 + 1) ) { setverdict(pass); } else { setverdict(fail); }; | |
926 | } | |
927 | ||
928 | testcase intIsbound() runs on intOper_comptype | |
929 | { | |
930 | var integer i0, i1 := 1; | |
931 | var template integer one_int := (13); | |
932 | var template integer two_ints := (1,2); | |
933 | ||
934 | if ( isbound(i0) ) { setverdict(fail); } else { setverdict(pass); }; | |
935 | if ( isbound(i1) ) { setverdict(pass); } else { setverdict(fail); }; | |
936 | if ( isbound(TintOper_const1) ) { setverdict(pass); } else { setverdict(fail); }; | |
937 | if ( isbound(one_int) ) { setverdict(pass); } else { setverdict(fail); }; | |
938 | if ( isbound(two_ints) ) { setverdict(pass); } else { setverdict(fail); }; | |
939 | ||
940 | if ( isbound(par_unbound) ) { setverdict(fail); } else { setverdict(pass); }; | |
941 | if ( isbound(par_bound) ) { setverdict(pass); } else { setverdict(fail); }; | |
942 | ||
943 | if ( isbound(i1 + 1) ) { setverdict(pass); } else { setverdict(fail); }; | |
944 | } | |
945 | ||
946 | testcase HO29687() runs on intOper_comptype { | |
947 | log(log2str(integer:1)); | |
948 | setverdict(pass); | |
949 | } | |
950 | ||
951 | testcase HO29695() runs on intOper_comptype { | |
952 | log(valueof(integer:1)); | |
953 | setverdict(pass); | |
954 | } | |
955 | ||
956 | testcase tc_simple_integer() runs on intOper_comptype { | |
957 | var integer vl_i; | |
958 | if(isbound(vl_i)){setverdict(fail)} else {setverdict(pass)} | |
959 | vl_i:=5; | |
960 | if(isbound(vl_i)) {setverdict(pass)} else {setverdict(fail)} | |
961 | ||
962 | var template integer vtl_i :=*; | |
963 | if(isbound( vtl_i )) {setverdict(pass)}else {setverdict(fail)}; | |
964 | vtl_i:=5; | |
965 | if(isbound( vtl_i )) {setverdict(pass)}else {setverdict(fail)}; | |
966 | } | |
967 | ||
968 | template integer t_i(integer i, integer j) :=i+j; | |
969 | ||
970 | testcase tc_runtimeExprEval() runs on intOper_comptype { | |
971 | var template integer vt_i:= t_i(1,2); | |
972 | var integer vl_i:=1, vl_j:=0; | |
973 | if(isbound(vt_i)) {setverdict(pass)} else {setverdict(fail)}; | |
974 | if(isbound(t_i(1,2))) {setverdict(pass)} else {setverdict(fail)}; | |
975 | if(isbound(t_i(1,2*vl_i))) {setverdict(pass)} else {setverdict(fail)}; | |
976 | //if(isbound(t_i(1,2/vl_j))) {setverdict(pass)} else {setverdict(fail)}; //DTE | |
977 | } | |
978 | ||
979 | testcase tc_simple_integer_unbound() runs on intOper_comptype { | |
980 | var integer vl_i; | |
981 | if(ispresent(vl_i)){setverdict(fail)} else {setverdict(pass)} //fail | |
982 | } | |
983 | ||
984 | testcase tc_simple_integer_value() runs on intOper_comptype { | |
985 | var integer vl_i:=5; | |
986 | if(ispresent(vl_i)) {setverdict(pass)} else {setverdict(fail)} //pass, | |
987 | } | |
988 | ||
989 | testcase tc_simple_integer_templ_asterix() runs on intOper_comptype { | |
990 | var template integer vtl_i :=*; | |
991 | if(ispresent( vtl_i )) {setverdict(fail)}else {setverdict(pass)}; | |
992 | } | |
993 | ||
994 | testcase tc_simple_integer_templ_qm() runs on intOper_comptype { | |
995 | var template integer vtl_i :=?; | |
996 | if(ispresent( vtl_i )) {setverdict(pass)}else {setverdict(fail)}; | |
997 | } | |
998 | ||
999 | testcase tc_simple_integer_templ_value() runs on intOper_comptype { | |
1000 | var template integer vtl_i:=5; | |
1001 | if(ispresent( vtl_i )) {setverdict(pass)}else {setverdict(fail)}; | |
1002 | } | |
1003 | ||
1004 | testcase tc_runtimeExprEval_ispresent() runs on intOper_comptype { | |
1005 | var template integer vt_i:= t_i(1,2); | |
1006 | var integer vl_i:=1, vl_j:=0; | |
1007 | if(ispresent(vt_i)) {setverdict(pass)} else {setverdict(fail)}; | |
1008 | if(ispresent(t_i(1,2))) {setverdict(pass)} else {setverdict(fail)}; | |
1009 | if(ispresent(t_i(1,2*vl_i))) {setverdict(pass)} else {setverdict(fail)}; | |
1010 | //if(ispresent(t_i(1,2/vl_j))) {setverdict(pass)} else {setverdict(fail)}; //DTE | |
1011 | } | |
1012 | ||
1013 | control { | |
1014 | const integer cl_1:=2; | |
1015 | var integer vl_1; | |
1016 | ||
1017 | execute(intAssign()); | |
1018 | execute(intConst()); | |
1019 | execute(intCompEq()); | |
1020 | execute(intCompNotEq()); | |
1021 | execute(intCompLess()); | |
1022 | execute(intCompLessEq()); | |
1023 | execute(intCompGreat()); | |
1024 | execute(intCompGreatEq()); | |
1025 | execute(intAdd()); | |
1026 | execute(intSubs()); | |
1027 | execute(intMultipl()); | |
1028 | execute(intDiv()); | |
1029 | execute(intMod()); | |
1030 | execute(intRem()); | |
1031 | execute(intSubtypes()); | |
1032 | /* | |
1033 | execute(intShiftRight1()); | |
1034 | execute(intShiftRight2()); | |
1035 | execute(intShiftRightSum()); | |
1036 | execute(intShiftLeft1()); | |
1037 | execute(intShiftLeft2()); | |
1038 | execute(intShiftLeftSum()); | |
1039 | */ | |
1040 | execute(bigIntConst()); | |
1041 | execute(bigIntVar()); | |
1042 | execute(bigIntTemplate()); | |
1043 | execute(bigIntVariableTemplate()); | |
1044 | execute(bigIntEnumerated()); | |
1045 | execute(bigIntRecord()); | |
1046 | execute(bigIntLogicalOps()); | |
1047 | execute(bigIntBasicArithmetic()); | |
1048 | execute(bigIntTemplateSendRecv()); | |
1049 | execute(bigIntOnTheEdge()); | |
1050 | execute(bigIntLongLong()); | |
1051 | ||
1052 | execute(intIsvalue()); | |
1053 | execute(intIsbound()); | |
1054 | ||
1055 | execute(HO29687()); | |
1056 | execute(HO29695()); | |
1057 | ||
1058 | execute(tc_simple_integer()); | |
1059 | execute(tc_runtimeExprEval()); | |
1060 | execute(tc_simple_integer_unbound()); | |
1061 | execute(tc_simple_integer_value()); | |
1062 | execute(tc_simple_integer_templ_asterix()); | |
1063 | execute(tc_simple_integer_templ_qm()); | |
1064 | execute(tc_simple_integer_templ_value()); | |
1065 | execute(tc_runtimeExprEval_ispresent()); | |
1066 | } | |
1067 | ||
1068 | } |