Sync with 5.1.0
[deliverable/titan.core.git] / regression_test / lazyEval / lazy_main.ttcn
CommitLineData
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 ******************************************************************************/
8module lazy_main {
9
10// Description:
11// The goal of this project is to test the feature "Lazy Parameter Evaluation"
12// described in chapter 4.29 of referenceguide.doc
13// Reference: Programmers's Technical Reference Guide for TITAN TTCN-3 Test Executor
14// 2/19817-CRL 113 200/3 Uen Rev C
15//
16// Import chain: lazy_main<-lazy_A<-lazy_B<-lazy_C
17//
18//
19
20import from lazy_defs all;
21import from lazy_A all;
22import from LazyASNTypes all;
23
24
25//****************************************
26//****************************************
27//**** Functions ****
28//****************************************
29//****************************************
30
31
32
33//****************************************
34//*** General functions ****
35//****************************************
36function f_verdict(in boolean pl_value) runs on MyComp {
37 if(pl_value) {setverdict(pass)} else {setverdict(fail)};
38 //log("value:", pl_value);
39}
40
41//****************************************
42//*** Functions returning with integer ***
43//****************************************
44
45group g_functions_returning_integer {
46
47 function f_fail() runs on MyComp return integer{
48 setverdict(fail);
49 return 1; //dummy
50 }
51
52 function f_returnOnefailIfIZero() runs on MyComp return integer{
53 if( v_i==0 ) {
54 setverdict(fail, "This function intentionally fails if v_i==0");
55 } else {
56 setverdict(pass, "This function intentionally pass if v_i!=0");
57 }
58 v_numberOfCalls:=v_numberOfCalls+1;
59 return 1;
60 }
61
62 function f_returnOnePassIfIZero() runs on MyComp return integer{
63 if( v_i==0 ) {
64 setverdict(pass, "This function intentionally pass if v_i==0");
65 }
66 v_numberOfCalls:=v_numberOfCalls+1;
67 return 1;
68 }
69
70 function f_returnOneWithCounterIncr() runs on MyComp return integer{
71 v_numberOfCalls:=v_numberOfCalls+1;
72 return 1;
73 }
74
75 //=======
76
77 function f_inout_b_inv_reti(inout boolean pl_b) runs on MyComp return integer{
78 pl_b := not pl_b
79 return 1;
80 }
81
82 function f_inout_i_inc(inout integer i) runs on MyComp return integer{
83 i:=i+1
84 return i;
85 }
86
87 function f_inout_f_inc_reti(inout float f) runs on MyComp return integer{
88 f:=f+1.0;
89 return float2int(f);
90 }
91
92 function f_inout_bs_4x_reti(inout bitstring bs) runs on MyComp return integer{
93 bs := bs & '00'B;
94 return bit2int(bs);
95 }
96
97 function f_inout_os_256x_reti(inout octetstring os) runs on MyComp return integer{
98 os := os & '00'O;
99 return oct2int(os);
100 }
101
102 function f_inout_hs_16x_reti(inout hexstring hs) runs on MyComp return integer{
103 hs := hs & '0'H;
104 return hex2int(hs);
105 }
106
107 function f_inout_cs_b_reti(inout charstring cs) runs on MyComp return integer{
108 cs := "b"
109 return char2int(cs);
110 }
111 /* lazy_main.ttcn:106.5-6: error: Reference to a variable or template variable was expected instead of timer parameter `cs'
112 function f_inout_timer_b_reti(inout timer pl_t) runs on MyComp return integer{
113 pl_t := 1.0;
114 return 1;
115 */
116
117 function f_inout_port_b_reti(inout My_PT pl_p) runs on MyComp return integer{
118 return 1;
119 }
120
121
122 //in template functions
123
124 function f_in_b_inv_reti_t(in template boolean pl_b) runs on MyComp return integer{
125 return 1;
126 }
127
128 function f_in_i_inc_reti_t(in template integer i) runs on MyComp return integer{
129 return valueof(i)+1;
130 }
131
132 function f_in_f_inc_reti_t(in template float f) runs on MyComp return integer{
133 return float2int(valueof(f))+1;
134 }
135
136 function f_in_bs_4x_reti_t(in template bitstring bs) runs on MyComp return integer{
137 return bit2int(valueof(bs) & '00'B);
138 }
139
140 function f_in_os_256x_reti_t(in template octetstring os) runs on MyComp return integer{
141 return oct2int(valueof(os) & '00'O);
142 }
143
144 function f_in_hs_16x_reti_t(in template hexstring hs) runs on MyComp return integer{
145 return hex2int(valueof(hs) & '0'H);
146 }
147
148 function f_in_cs_b_reti_t(in template charstring pl_cs) runs on MyComp return integer{
149 return char2int(valueof(pl_cs))+1;
150 }
151
152 //inout template functions:
153
154 function f_inout_b_inv_reti_t(inout template boolean pl_b) runs on MyComp return integer{
155 pl_b := not valueof(pl_b);
156 return 1;
157 }
158
159 function f_inout_i_inc_t(inout template integer i) runs on MyComp return integer{
160 i:=valueof(i)+1
161 return valueof(i);
162 }
163
164 function f_inout_f_inc_reti_t(inout template float f) runs on MyComp return integer{
165 f:=valueof(f)+1.0;
166 return float2int(valueof(f));
167 }
168
169 function f_inout_bs_4x_reti_t(inout template bitstring bs) runs on MyComp return integer{
170 bs := valueof(bs) & '00'B;
171 return bit2int(valueof(bs));
172 }
173
174 function f_inout_os_256x_reti_t(inout template octetstring os) runs on MyComp return integer{
175 os := valueof(os) & '00'O;
176 return oct2int(valueof(os));
177 }
178
179 function f_inout_hs_16x_reti_t(inout template hexstring hs) runs on MyComp return integer{
180 hs := valueof(hs) & '0'H;
181 return hex2int(valueof(hs));
182 }
183
184 function f_inout_cs_b_reti_t(inout template charstring cs) runs on MyComp return integer{
185 cs := "b"
186 return char2int(valueof(cs));
187 }
188
189 //out template functions:
190
191 function f_out_b_inv_reti_t(out template boolean pl_b) runs on MyComp return integer{
192 pl_b := false;
193 return 1;
194 }
195
196 function f_out_i_inc_t(out template integer i) runs on MyComp return integer{
197 i:=2
198 return valueof(i);
199 }
200
201 function f_out_f_inc_reti_t(out template float f) runs on MyComp return integer{
202 f:=2.0
203 return float2int(valueof(f));
204 }
205
206 function f_out_bs_4x_reti_t(out template bitstring bs) runs on MyComp return integer{
207 bs := '100'B;
208 return bit2int(valueof(bs));
209 }
210
211 function f_out_os_256x_reti_t(out template octetstring os) runs on MyComp return integer{
212 os := '5500'O;
213 return oct2int(valueof(os));
214 }
215
216 function f_out_hs_16x_reti_t(out template hexstring hs) runs on MyComp return integer{
217 hs := 'f0'H;
218 return hex2int(valueof(hs));
219 }
220
221 function f_out_cs_b_reti_t(out template charstring cs) runs on MyComp return integer{
222 cs := "b"
223 return char2int(valueof(cs));
224 }
225
226 // Without import
227
228 //test for lazy function in main module with integer integer arg
229 function f_lazy_mi( in @lazy integer pl_i, in boolean pl_evalFlag) runs on MyComp {
230 if(pl_evalFlag){
231 v_i:= pl_i; //expression evaluated
232 }
233 log("Inside lazy:", v_i);
234
235 }
236
237 function f_lazy_mi_2(in boolean pl_evalFlag, in @lazy integer pl_i) runs on MyComp {
238 if(pl_evalFlag){
239 v_i:= pl_i; //expression evaluated
240 }
241 log("Inside lazy:", v_i);
242
243 }
244
245 //test for lazy function in main module with integer integer arg
246 //expression used more than once
247 function f_lazy_mi_3( in @lazy integer pl_i, in boolean pl_evalFlag) runs on MyComp {
248 if(pl_evalFlag){
249 v_i:= pl_i; //expression evaluated
250 log(pl_i);
251 }
252
253 log("Inside lazy:", v_i, pl_i);
254 }
255 // Lazy function calling lazy function from the same module:
256 function f_lazy_mmi( in @lazy integer pl_j, in boolean pl_evalFlag) runs on MyComp {
257 f_lazy_mi(pl_j, pl_evalFlag)
258 }
259
260 // Lazy function calling lazy function from the same module:
261 function f_lazy_mmmi( in @lazy integer pl_k, in boolean pl_evalFlag) runs on MyComp {
262 f_lazy_mmi(pl_k, pl_evalFlag)
263 }
264
265 // With import
266 // Lazy function calling lazy function from another module:
267 function f_lazy_mABi( in @lazy integer pl_j, in boolean pl_evalFlag) runs on MyComp {
268 f_lazy_ABi(pl_j, pl_evalFlag)
269 }
270
271 //These functions do the same as tc_mi_1 -> tc_mi_5: call lazy function f_lazy_mi()
272 function f_fmi_1() runs on MyComp {
273 f_lazy_mi(2+3*4, true);
274 f_verdict(v_i==14);
275 }
276
277 function f_fmi_2() runs on MyComp {
278 f_lazy_mi(f_fail(), false);
279 f_verdict(v_i==0);
280 }
281
282 function f_fmi_3() runs on MyComp {
283 v_i:=0;
284 f_lazy_mi(10*f_returnOnefailIfIZero(), false);
285 f_verdict(v_i==0);
286 }
287
288 function function_fmi_3a() runs on MyComp {
289 v_i:=1;
290 f_lazy_mi(10*f_returnOnefailIfIZero(), false);
291 f_verdict(v_i==1);
292 }
293
294 function f_fmi_4() runs on MyComp {
295 v_i:=0;
296 f_lazy_mi(10*f_returnOnePassIfIZero(), true);
297 f_verdict(getverdict == pass);
298 f_verdict(v_i==10);
299 }
300
301 function f_fmi_5() runs on MyComp {
302 v_i:=1;
303 f_lazy_mi(10*f_returnOnefailIfIZero(), true);
304 f_verdict(v_i==10);
305 }
306
307 //These functions do the same as tc_mi_1 -> tc_mi_5: call lazy function f_lazy_mi()
308 function f_fAi_1() runs on MyComp {
309 f_lazy_Ai(2+3*4, true);
310 f_verdict(v_i==14);
311 }
312
313 function f_fAi_2() runs on MyComp {
314 f_lazy_Ai(f_fail(), false);
315 f_verdict(v_i==0);
316 }
317
318 function f_fAi_3() runs on MyComp {
319 v_i:=0;
320 f_lazy_Ai(10*f_returnOnefailIfIZero(), false);
321 f_verdict(v_i==0);
322 }
323
324 function function_fAi_3a() runs on MyComp {
325 v_i:=1;
326 f_lazy_Ai(10*f_returnOnefailIfIZero(), false);
327 f_verdict(v_i==1);
328 }
329
330 function f_fAi_4() runs on MyComp {
331 v_i:=0;
332 f_lazy_Ai(10*f_returnOnePassIfIZero(), true);
333 f_verdict(getverdict == pass);
334 f_verdict(v_i==10);
335 }
336
337 function f_fAi_5() runs on MyComp {
338 v_i:=1;
339 f_lazy_Ai(10*f_returnOnefailIfIZero(), true);
340 f_verdict(v_i==10);
341 }
342
343} //g_functions_returning_integer
344
345
346group g_float_functions {
347
348 //test for lazy function in main module with integer float arg
349 function f_lazy_mf( in @lazy float pl_f, in boolean pl_evalFlag) runs on MyComp {
350 if(pl_evalFlag){
351 v_f:= pl_f; //expression evaluated
352 log(pl_f); //second usage
353 }
354 log("Inside lazy:", v_f);
355
356 }
357
358 function f_lazy_mf_2(in boolean pl_evalFlag, in @lazy float pl_f) runs on MyComp {
359 if(pl_evalFlag){
360 v_f:= pl_f; //expression evaluated
361 }
362 log("Inside lazy:", v_i);
363
364 }
365
366 // Lazy function calling lazy function from the same module:
367 function f_lazy_mmf( in @lazy float pl_f, in boolean pl_evalFlag) runs on MyComp {
368 f_lazy_mf(pl_f,pl_evalFlag);
369 }
370
371 function f_lazy_mmf_2(in boolean pl_evalFlag, in @lazy float pl_f) runs on MyComp {
372 f_lazy_mf(pl_f,pl_evalFlag);
373 }
374
375 // Without import
376 //basic behavior for integer arg expression:
377 function f_mf_1() runs on MyComp {
378 f_lazy_mf(2.1+3.5*4.4, true);
379 if(v_f==2.1+3.5*4.4) {setverdict(pass)} else {setverdict(fail)};
380 }
381
382
383 //The goal of this testcase
384 //to test if expression is not evaluated if the condition is false
385 function f_mf_3() runs on MyComp {
386 v_f:=0.0;
387 v_i:=0;
388 f_lazy_mf(10.0*int2float(f_returnOnefailIfIZero()), false);
389 f_verdict(v_f==0.0);
390 }
391
392 //The goal of this testcase
393 //to test if expression is not evaluated if the condition is false
394 function f_mf_3a() runs on MyComp {
395 v_i:=1;
396 f_lazy_mf(10.0*int2float(f_returnOnefailIfIZero()), false);
397 f_verdict(v_f==0.0);
398 }
399
400 function f_mf_4() runs on MyComp {
401 v_i:=0;
402 f_lazy_mf(10.0*int2float(f_returnOnePassIfIZero()), true);
403 f_verdict(getverdict == pass);
404 f_verdict(v_f==10.0);
405 }
406
407 function f_mf_5() runs on MyComp {
408 v_i:=1;
409 f_lazy_mf(10.0*int2float(f_returnOnefailIfIZero()), true);
410 f_verdict(v_f==10.0);
411 }
412
413}//g_float_functions
414
415group g_charstring_functions {
416
417 function f_returnHelloPassWithZero() runs on MyComp return charstring {
418 if(v_i==0) { setverdict(pass, "This function intentionally pass if v_i==0");}
419 v_numberOfCalls:=v_numberOfCalls+1;
420 return "Hello";
421 }
422
423 //test for lazy function in main module with integer lazy arg:
424 function f_lazy_mc(in @lazy charstring pl_c, in boolean pl_evalFlag) runs on MyComp {
425 if(pl_evalFlag){
426 v_c:= pl_c; //expression evaluated
427 log("expression:",pl_c); //expression used once more
428 }
429 }
430
431 function f_mc_wrapper_in(
432 in boolean b,
433 in integer i,
434 in float f,
435 in bitstring bs,
436 in octetstring os,
437 in hexstring hs,
438 in charstring cs,
439 in MyRec rec,
440 in boolean pl_evalFlag
441 ) runs on MyComp
442 {
443 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs(b)&" "&f_in_i_inc_retcs(i)&" "&
444 f_in_f_inc_retcs(f)&" "&f_in_bs_4x_retcs(bs)&" "&f_in_os_256x_retcs(os)&" "&
445 f_in_hs_16x_retcs(hs)&" "&f_in_cs_b_retcs(cs)&" "&
446 f_in_port_retcs(PCO)&" "&f_in_b_inv_retcs(rec.b)&" "&f_in_i_inc_retcs(rec.i),
447 pl_evalFlag);
448 }
449
450 function f_mc_wrapper_inout_in(
451 inout boolean b,
452 inout integer i,
453 inout float f,
454 inout bitstring bs,
455 inout octetstring os,
456 inout hexstring hs,
457 inout charstring cs,
458 inout MyRec rec,
459 in boolean pl_evalFlag
460 ) runs on MyComp
461 {
462 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs(b)&" "&f_in_i_inc_retcs(i)&" "&
463 f_in_f_inc_retcs(f)&" "&f_in_bs_4x_retcs(bs)&" "&f_in_os_256x_retcs(os)&" "&
464 f_in_hs_16x_retcs(hs)&" "&f_in_cs_b_retcs(cs)&" "&
465 f_in_port_retcs(PCO)&" "&f_in_b_inv_retcs(rec.b)&" "&f_in_i_inc_retcs(rec.i),
466 pl_evalFlag);
467 }
468
469 function f_mc_wrapper_inout_inout(
470 inout boolean b,
471 inout integer i,
472 inout float f,
473 inout bitstring bs,
474 inout octetstring os,
475 inout hexstring hs,
476 inout charstring cs,
477 inout MyRec rec,
478 in boolean pl_evalFlag
479 ) runs on MyComp
480 {
481 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_inout_b_inv_retcs(b)&" "&f_inout_i_inc_retcs(i)&" "&
482 f_inout_f_inc_retcs(f)&" "&f_inout_bs_4x_retcs(bs)&" "&f_inout_os_256x_retcs(os)&" "&
483 f_inout_hs_16x_retcs(hs)&" "&f_inout_cs_b_retcs(cs)&" "&
484 f_inout_port_retcs(PCO)&" "&f_inout_b_inv_retcs(rec.b)&" "&f_inout_i_inc_retcs(rec.i),
485 pl_evalFlag);
486 }
487
488 //in functions
489 function f_in_b_inv_retcs(in boolean pl_b) runs on MyComp return charstring{
490 return "false";
491 }
492
493 function f_in_i_inc_retcs(in integer i) runs on MyComp return charstring{
494 return int2str(i+1);
495 }
496
497 function f_in_f_inc_retcs(in float f) runs on MyComp return charstring{
498 return float2str(f+1.0);
499 }
500
501 function f_in_bs_4x_retcs(in bitstring bs) runs on MyComp return charstring{
502 return bit2str(bs & '00'B);
503 }
504
505 function f_in_os_256x_retcs(in octetstring os) runs on MyComp return charstring{
506 return oct2str(os & '00'O);
507 }
508
509 function f_in_hs_16x_retcs(in hexstring hs) runs on MyComp return charstring{
510 return hex2str(hs & '0'H);
511 }
512
513 function f_in_cs_b_retcs(in charstring cs) runs on MyComp return charstring{
514 return "b";
515 }
516
517 function f_in_port_retcs_legal(inout My_PT p) runs on MyComp return charstring{
518 return log2str(p);
519 }
520
521 function f_in_port_retcs(inout My_PT p) runs on MyComp return charstring{ //TODO: change it to f_in_port_retcs(inout My_PT p) if accepted
522 return log2str(p);
523 }
524
525 //inout
526 function f_inout_b_inv_retcs(inout boolean pl_b) runs on MyComp return charstring{
527 pl_b := not pl_b
528 return "false";
529 }
530
531 function f_inout_i_inc_retcs(inout integer i) runs on MyComp return charstring{
532 i:=i+1
533 return int2str(i);
534 }
535
536 function f_inout_f_inc_retcs(inout float f) runs on MyComp return charstring{
537 f:=f+1.0;
538 return float2str(f);
539 }
540
541 function f_inout_bs_4x_retcs(inout bitstring bs) runs on MyComp return charstring{
542 bs := bs & '00'B;
543 return bit2str(bs);
544 }
545
546 function f_inout_os_256x_retcs(inout octetstring os) runs on MyComp return charstring{
547 os := os & '00'O;
548 return oct2str(os);
549 }
550
551 function f_inout_hs_16x_retcs(inout hexstring hs) runs on MyComp return charstring{
552 hs := hs & '0'H;
553 return hex2str(hs);
554 }
555
556 function f_inout_cs_b_retcs(inout charstring cs) runs on MyComp return charstring{
557 cs := "b"
558 return cs;
559 }
560
561 function f_inout_port_retcs(inout My_PT p) runs on MyComp return charstring{
562 return log2str(p);
563 }
564
565 //out
566 function f_out_b_inv_retcs(out boolean pl_b) runs on MyComp return charstring{
567 return "false";
568 }
569
570 function f_out_i_inc_retcs(out integer i) runs on MyComp return charstring{
571 return "2";
572 }
573
574 function f_out_f_inc_retcs(out float f) runs on MyComp return charstring{
575 return "2.000000";
576 }
577
578 function f_out_bs_4x_retcs(out bitstring bs) runs on MyComp return charstring{
579 return "100";
580 }
581
582 function f_out_os_256x_retcs(out octetstring os) runs on MyComp return charstring{
583 return "5500";
584 }
585
586 function f_out_hs_16x_retcs(out hexstring hs) runs on MyComp return charstring{
587 return "F0";
588 }
589
590 function f_out_cs_b_retcs(out charstring cs) runs on MyComp return charstring{
591 return "b";
592 }
593
594 //in template functions
595
596 function f_in_b_inv_retcs_t(in template boolean pl_b) runs on MyComp return charstring{
597 return "false";
598 }
599
600 function f_in_i_inc_retcs_t(in template integer i) runs on MyComp return charstring{
601 return int2str(valueof(i)+1);
602 }
603
604 function f_in_f_inc_retcs_t(in template float f) runs on MyComp return charstring{
605 return float2str(valueof(f)+1.0);
606 }
607
608 function f_in_bs_4x_retcs_t(in template bitstring bs) runs on MyComp return charstring{
609 return bit2str(valueof(bs) & '00'B);
610 }
611
612 function f_in_os_256x_retcs_t(in template octetstring os) runs on MyComp return charstring{
613 return oct2str(valueof(os) & '00'O);
614 }
615
616 function f_in_hs_16x_retcs_t(in template hexstring hs) runs on MyComp return charstring{
617 return hex2str(valueof(hs) & '0'H);
618 }
619
620 function f_in_cs_b_retcs_t(in template charstring cs) runs on MyComp return charstring{
621 return "b";
622 }
623
624 //inout template functions:
625
626 function f_inout_b_inv_retcs_t(inout template boolean pl_b) runs on MyComp return charstring{
627 pl_b := not valueof(pl_b);
628 return "false";
629 }
630
631 function f_inout_i_inc_retcs_t(inout template integer i) runs on MyComp return charstring{
632 i:=valueof(i)+1
633 return int2str(valueof(i));
634 }
635
636 function f_inout_f_inc_retcs_t(inout template float f) runs on MyComp return charstring{
637 f:=valueof(f)+1.0;
638 return float2str(valueof(f));
639 }
640
641 function f_inout_bs_4x_retcs_t(inout template bitstring bs) runs on MyComp return charstring{
642 bs := valueof(bs) & '00'B;
643 return bit2str(valueof(bs));
644 }
645
646 function f_inout_os_256x_retcs_t(inout template octetstring os) runs on MyComp return charstring{
647 os := valueof(os) & '00'O;
648 return oct2str(valueof(os));
649 }
650
651 function f_inout_hs_16x_retcs_t(inout template hexstring hs) runs on MyComp return charstring{
652 hs := valueof(hs) & '0'H;
653 return hex2str(valueof(hs));
654 }
655
656 function f_inout_cs_b_retcs_t(inout template charstring cs) runs on MyComp return charstring{
657 cs := "b"
658 return valueof(cs);
659 }
660
661 //out template functions:
662
663 function f_out_b_inv_retcs_t(out template boolean pl_b) runs on MyComp return charstring{
664 return "false";
665 }
666
667 function f_out_i_inc_retcs_t(out template integer i) runs on MyComp return charstring{
668 return "2";
669 }
670
671 function f_out_f_inc_retcs_t(out template float f) runs on MyComp return charstring{
672 return "2.000000";
673 }
674
675 function f_out_bs_4x_retcs_t(out template bitstring bs) runs on MyComp return charstring{
676 return "100"
677 }
678
679 function f_out_os_256x_retcs_t(out template octetstring os) runs on MyComp return charstring{
680 return "5500";
681 }
682
683 function f_out_hs_16x_retcs_t(out template hexstring hs) runs on MyComp return charstring{
684 return "F0";
685 }
686
687 function f_out_cs_b_retcs_t(out template charstring cs) runs on MyComp return charstring{
688 return "b";
689 }
690
691
692}//g_charstring_functions
693
694group g_rec_functions {
695
696 function f_returnRec(in integer pl_i, in ROI pl_roi, in boolean pl_b) runs on MyComp return MyRec {
697 v_numberOfCalls:=v_numberOfCalls+1;
698 return { pl_i,pl_roi,pl_b }
699
700 }
701 function f_lazy_mrec(in @lazy MyRec pl_rec, in boolean pl_evalFlag) runs on MyComp {
702 if(pl_evalFlag){
703 v_rec:=pl_rec;
704 log("rec:", pl_rec);
705 }
706 }
707
708}// g_rec_functions
709
710//****************************************
711//*** Templates ***
712//****************************************
713
714template MyRec t_lazy_rec( template @lazy integer p_i, template @lazy ROI p_roi, template @lazy boolean p_b) := {
715 i:= p_i,
716 roi:=p_roi,
717 b:=p_b
718}
719
720template MyRec t_rec( template integer p_i, template ROI p_roi, template boolean p_b) := {
721 i:= p_i,
722 roi:=p_roi,
723 b:=p_b
724}
725
726//not used first argument:
727template MyRec t_lazy_rec1( template @lazy integer p_i, template @lazy ROI p_roi, template @lazy boolean p_b) := {
728 i:= 1,
729 roi:=p_roi,
730 b:=p_b
731}
732
733//****************************************
734//*** Templates ***
735//****************************************
736//****************************************
737
738//This altstep is wrong:
739
740altstep as_lazy_mi(in @lazy integer pl_i, in boolean pl_evalFlag) runs on MyComp{
741 [pl_evalFlag] PCO.receive {log("valami")}
742 [else] {
743 if(pl_evalFlag) {
744 v_i:=pl_i;
745 log(pl_i);
746 }
747 }
748}
749
750altstep as_lazy_mf(in @lazy float pl_f, in boolean pl_evalFlag) runs on MyComp{
751 [pl_evalFlag] PCO.receive {log("valami")}
752 [else] {
753 if(pl_evalFlag) {
754 v_f:=pl_f;
755 log(pl_f);
756 }
757 }
758}
759
760//****************************************
761//***** Testcases *****
762//****************************************
763//****************************************
764group g_lazy_integer_arg_tc {
765 //==============================
766 //==== Lazy called in testcase =
767 //==============================
768 // Without import
769 //basic behavior for integer arg expression:
770 testcase tc_mi_1() runs on MyComp {
771 f_lazy_mi(2+3*4, true);
772 if(v_i==14) {setverdict(pass)} else {setverdict(fail)};
773 }
774
775 testcase tc_mi_2() runs on MyComp {
776 f_lazy_mi(f_fail(), false);
777 f_verdict(v_i==0);
778 }
779
780 //The goal of this testcase
781 //to test if expression is not evaluated if the condition is false
782 testcase tc_mi_3() runs on MyComp {
783 v_i:=0;
784 f_lazy_mi(10*f_returnOnefailIfIZero(), false);
785 f_verdict(v_i==0);
786 }
787
788 //The goal of this testcase
789 //to test if expression is not evaluated if the condition is false
790 testcase tc_mi_3a() runs on MyComp {
791 v_i:=1;
792 f_lazy_mi(10*f_returnOnefailIfIZero(), false);
793 f_verdict(v_i==1);
794 }
795
796 testcase tc_mi_4() runs on MyComp {
797 v_i:=0;
798 f_lazy_mi(10*f_returnOnePassIfIZero(), true);
799 f_verdict(getverdict == pass);
800 f_verdict(v_i==10);
801 }
802
803 testcase tc_mi_5() runs on MyComp {
804 v_i:=1;
805 f_lazy_mi(10*f_returnOnefailIfIZero(), true);
806 f_verdict(v_i==10);
807 }
808
809
810 // the lazy arg is not the first arg:
811 testcase tc_mi_6() runs on MyComp {
812 v_i:=1;
813 f_lazy_mi_2(true, 10*f_returnOnefailIfIZero());
814 f_verdict(v_i==10);
815 }
816
817 // f_lazy_mi_3 uses expression more than once
818 //expression shall be evaluated only once
819 testcase tc_mi_7() runs on MyComp {
820 v_i:=1;
821 f_lazy_mi_3(10*f_returnOneWithCounterIncr(),true);
822 f_verdict(v_i==10 and v_numberOfCalls==1);
823 }
824
825 //====================================================
826 // lazy argument contains inout parameters +in params
827 //====================================================
828 type record R { integer i, float f }
829
830 testcase tc_mi_1_in() runs on MyComp {
831 v_i:=1;
832 var boolean b:=true;
833 var integer i:=1;
834 var float f:= 1.0;
835 var bitstring bs:='1'B;
836 var octetstring os:='55'O;
837 var hexstring hs:='F'H;
838 var charstring cs:="a";
839 var R r:= { i:=1, f:=1.0}
840 f_lazy_mi(i+float2int(f)+bit2int(bs)+oct2int(os)+hex2int(hs)+char2int(cs)+r.i+float2int(r.f), true);
841 if(v_i==88+15+97+2 and i==1 and b==true and f==1.0 and bs=='1'B and os=='55'O and hs=='F'H and cs=="a") {setverdict(pass)} else {setverdict(fail)};
842 }
843
844 testcase tc_mi_2_in() runs on MyComp {
845 v_i:=1;
846 var boolean b:=true;
847 var integer i:=1;
848 var float f:= 1.0;
849 var bitstring bs:='1'B;
850 var octetstring os:='55'O;
851 var hexstring hs:='F'H;
852 var charstring cs:="a";
853 var R r:= { i:=1, f:=1.0}
854 f_lazy_mi(i+float2int(f)+bit2int(bs)+oct2int(os)+hex2int(hs)+char2int(cs)+r.i+float2int(r.f),false);
855 if(v_i==1 and i==1 and b==true and f==1.0 and bs=='1'B and os=='55'O and hs=='F'H and cs=="a") {setverdict(pass)} else {setverdict(fail)};
856 }
857
858 testcase tc_mi_1_inout() runs on MyComp {
859 v_i:=1;
860 var boolean b:=true;
861 var integer i:=1;
862 var float f:= 1.0;
863 var bitstring bs:='1'B;
864 var octetstring os:='55'O;
865 var hexstring hs:='F'H;
866 var charstring cs:="a";
867 var R r:= {i:=1, f:=1.0};
868 f_lazy_mi(f_inout_i_inc(i)+f_inout_b_inv_reti(b)+f_inout_f_inc_reti(f)+f_inout_bs_4x_reti(bs)+
869 f_inout_os_256x_reti(os)+f_inout_hs_16x_reti(hs)+f_inout_cs_b_reti(cs)+f_inout_i_inc(r.i)+f_inout_f_inc_reti(r.f)+f_inout_port_b_reti(PCO)+f_returnOneWithCounterIncr(), true);
870 //v_i = 2 + 1 + 2 + + 4 = 9
871 if(v_i==9+256*85+15*16+98+2+2+1+1 and i==2 and b==false and f==2.0 and bs=='100'B and os=='5500'O and hs=='F0'H and cs=="b"and r=={ i:=2, f:=2.0} and v_numberOfCalls==1) {setverdict(pass)} else {setverdict(fail)};
872 }
873
874
875
876 testcase tc_mi_2_inout() runs on MyComp {
877 v_i:=1;
878 var boolean b:=true;
879 var integer i:=1;
880 var float f:= 1.0;
881 var bitstring bs:='1'B;
882 var octetstring os:='55'O;
883 var hexstring hs:='F'H;
884 var charstring cs:="a";
885 var R r:= { i:=1, f:=1.0}
886 f_lazy_mi(f_inout_i_inc(i)+f_inout_b_inv_reti(b)+f_inout_f_inc_reti(f)+i+float2int(f)+f_inout_bs_4x_reti(bs)+
887 f_inout_os_256x_reti(os)+f_inout_hs_16x_reti(hs)+f_inout_cs_b_reti(cs)+f_inout_i_inc(r.i)+f_inout_f_inc_reti(r.f)+f_inout_port_b_reti(PCO)+f_returnOneWithCounterIncr(), false);
888 if(v_i==1 and i==1 and b==true and f==1.0 and bs=='1'B and os=='55'O and hs=='F'H and cs=="a") {setverdict(pass)} else {setverdict(fail)};
889 }
890
891 //in templates
892
893 testcase tc_mi_1_in_t() runs on MyComp {
894 v_i:=1;
895 var template boolean b:=true;
896 var template integer i:=1;
897 var template float f:= 1.0;
898 var template bitstring bs:='1'B;
899 var template octetstring os:='55'O;
900 var template hexstring hs:='F'H;
901 var template charstring cs:="a";
902 var template R r:= { i:=1, f:=1.0}
903 f_lazy_mi(f_in_i_inc_reti_t(i)+f_in_b_inv_reti_t(b)+f_in_f_inc_reti_t(f)+f_in_bs_4x_reti_t(bs)+
904 f_in_os_256x_reti_t(os)+f_in_hs_16x_reti_t(hs)+f_in_cs_b_reti_t(cs)+f_in_i_inc_reti_t(r.i)+f_in_f_inc_reti_t(r.f)+f_returnOneWithCounterIncr(), true);
905 //v_i = 2 + 1 + 2 + + 4 = 9
906 //
907 log(f_in_os_256x_reti_t(os)," ",f_in_hs_16x_reti_t(hs)," ",f_in_cs_b_reti_t(cs));
908 if(v_i==9+256*85+15*16+98+2+2+1) {setverdict(pass)} else {setverdict(fail)};
909 if(valueof(i)==1 and valueof(b)==true and
910 valueof(f)==1.0 and valueof(bs)=='1'B and valueof(os)=='55'O and valueof(hs)=='F'H and valueof(cs)=="a" and valueof(r)=={ i:=1, f:=1.0} and v_numberOfCalls==1)
911 {setverdict(pass)} else {setverdict(fail)};
912 }
913
914 testcase tc_mi_2_in_t() runs on MyComp {
915 v_i:=1;
916 var template boolean b:=true;
917 var template integer i:=1;
918 var template float f:= 1.0;
919 var template bitstring bs:='1'B;
920 var template octetstring os:='55'O;
921 var template hexstring hs:='F'H;
922 var template charstring cs:="a";
923 f_lazy_mi(f_in_i_inc_reti_t(i)+f_in_b_inv_reti_t(b)+f_in_f_inc_reti_t(f)+f_in_bs_4x_reti_t(bs)+f_in_os_256x_reti_t(os)+f_in_hs_16x_reti_t(hs)+f_in_cs_b_reti_t(cs)+f_returnOneWithCounterIncr(), false);
924 if(v_i==1 and valueof(i)==1 and valueof(b)==true and valueof(f)==1.0 and
925 valueof(bs)=='1'B and valueof(os)=='55'O and valueof(hs)=='F'H and valueof(cs)=="a" and v_numberOfCalls==0)
926 {setverdict(pass)} else {setverdict(fail)};
927 }
928
929 //inout templates
930 testcase tc_mi_1_inout_t() runs on MyComp {
931 v_i:=1;
932 var template boolean b:=true;
933 var template integer i:=1;
934 var template float f:= 1.0;
935 var template bitstring bs:='1'B;
936 var template octetstring os:='55'O;
937 var template hexstring hs:='F'H;
938 var template charstring cs:="a";
939 f_lazy_mi(f_inout_i_inc_t(i)+f_inout_b_inv_reti_t(b)+f_inout_f_inc_reti_t(f)+f_inout_bs_4x_reti_t(bs)+
940 f_inout_os_256x_reti_t(os)+f_inout_hs_16x_reti_t(hs)+f_inout_cs_b_reti_t(cs)+f_returnOneWithCounterIncr(), true);
941 //v_i = 2 + 1 + 2 + + 4 = 9
942 if(v_i==9+256*85+15*16+98+1 and valueof(i)==2 and valueof(b)==false and
943 valueof(f)==2.0 and valueof(bs)=='100'B and valueof(os)=='5500'O and valueof(hs)=='F0'H and valueof(cs)=="b" and v_numberOfCalls==1)
944 {setverdict(pass)} else {setverdict(fail)};
945 }
946
947 testcase tc_mi_2_inout_t() runs on MyComp {
948 v_i:=1;
949 var template boolean b:=true;
950 var template integer i:=1;
951 var template float f:= 1.0;
952 var template bitstring bs:='1'B;
953 var template octetstring os:='55'O;
954 var template hexstring hs:='F'H;
955 var template charstring cs:="a";
956 f_lazy_mi(f_inout_i_inc_t(i)+f_inout_b_inv_reti_t(b)+f_inout_f_inc_reti_t(f)+f_inout_bs_4x_reti_t(bs)+f_inout_os_256x_reti_t(os)+f_inout_hs_16x_reti_t(hs)+f_inout_cs_b_reti_t(cs), false);
957 if(v_i==1 and valueof(i)==1 and valueof(b)==true and valueof(f)==1.0 and
958 valueof(bs)=='1'B and valueof(os)=='55'O and valueof(hs)=='F'H and valueof(cs)=="a")
959 {setverdict(pass)} else {setverdict(fail)};
960 }
961
962
963 //inout templates
964 testcase tc_mi_1_out_t() runs on MyComp {
965 v_i:=1;
966 var template boolean b:=true;
967 var template integer i:=1;
968 var template float f:= 1.0;
969 var template bitstring bs:='1'B;
970 var template octetstring os:='55'O;
971 var template hexstring hs:='F'H;
972 var template charstring cs:="a";
973 f_lazy_mi(f_out_i_inc_t(i)+f_out_b_inv_reti_t(b)+f_out_f_inc_reti_t(f)+f_out_bs_4x_reti_t(bs)+
974 f_out_os_256x_reti_t(os)+f_out_hs_16x_reti_t(hs)+f_out_cs_b_reti_t(cs), true);
975 //v_i = 2 + 1 + 2 + + 4 = 9
976 if(v_i==9+256*85+15*16+98 and valueof(i)==2 and valueof(b)==false and
977 valueof(f)==2.0 and valueof(bs)=='100'B and valueof(os)=='5500'O and valueof(hs)=='F0'H and valueof(cs)=="b")
978 {setverdict(pass)} else {setverdict(fail)};
979 }
980
981 testcase tc_mi_2_out_t() runs on MyComp {
982 v_i:=1;
983 var template boolean b:=true;
984 var template integer i:=1;
985 var template float f:= 1.0;
986 var template bitstring bs:='1'B;
987 var template octetstring os:='55'O;
988 var template hexstring hs:='F'H;
989 var template charstring cs:="a";
990 f_lazy_mi(f_out_i_inc_t(i)+f_out_b_inv_reti_t(b)+f_out_f_inc_reti_t(f)+f_out_bs_4x_reti_t(bs)+f_out_os_256x_reti_t(os)+f_out_hs_16x_reti_t(hs)+f_out_cs_b_reti_t(cs), false);
991 if(v_i==1 and valueof(i)==1 and valueof(b)==true and valueof(f)==1.0 and
992 valueof(bs)=='1'B and valueof(os)=='55'O and valueof(hs)=='F'H and valueof(cs)=="a")
993 {setverdict(pass)} else {setverdict(fail)};
994 }
995 // lazy argument contains function calls with inout parameters
996
997 //=================
998 //Lazy calls lazy
999 //=================
1000 testcase tc_mmi_1() runs on MyComp {
1001 f_lazy_mmi(2+3*4, true);
1002 f_verdict(v_i==14);
1003 }
1004
1005 testcase tc_mmi_1b() runs on MyComp {
1006 f_lazy_mmi(2, false);
1007 f_verdict(v_i==0);
1008 }
1009
1010 testcase tc_mmi_2() runs on MyComp {
1011 f_lazy_mmi(f_fail(), false);
1012 f_verdict(v_i==0);
1013 }
1014
1015
1016 testcase tc_mmi_3() runs on MyComp {
1017 v_i:=0;
1018 f_lazy_mmi(10*f_returnOnefailIfIZero(), false);
1019 f_verdict(v_i==0);
1020 }
1021
1022 testcase tc_mmi_3a() runs on MyComp {
1023 v_i:=1;
1024 f_lazy_mmi(10*f_returnOnefailIfIZero(), false);
1025 f_verdict(v_i==1);
1026 }
1027
1028 testcase tc_mmi_4() runs on MyComp {
1029 v_i:=0;
1030 f_lazy_mmi(10*f_returnOnePassIfIZero(), true);
1031 f_verdict(getverdict == pass);
1032 f_verdict(v_i==10);
1033 }
1034
1035 testcase tc_mmi_5() runs on MyComp {
1036 v_i:=1;
1037 f_lazy_mmi(10*f_returnOnefailIfIZero(), true);
1038 f_verdict(v_i==10);
1039 }
1040 //==============================
1041 //Lazy calls lazy who calls lazy
1042 //==============================
1043 testcase tc_mmmi_1() runs on MyComp {
1044 f_lazy_mmmi(2*4, true);
1045 if(v_i==8) {setverdict(pass)} else {setverdict(fail)};
1046 }
1047 testcase tc_mmmi_1b() runs on MyComp {
1048 f_lazy_mmmi(2, false);
1049 f_verdict(v_i==0);
1050 }
1051
1052 testcase tc_mmmi_2() runs on MyComp {
1053 f_lazy_mmmi(f_fail(), false);
1054 f_verdict(v_i==0);
1055 }
1056
1057
1058 testcase tc_mmmi_3() runs on MyComp {
1059 v_i:=0;
1060 f_lazy_mmmi(10*f_returnOnefailIfIZero(), false);
1061 f_verdict(v_i==0);
1062 }
1063
1064 testcase tc_mmmi_3a() runs on MyComp {
1065 v_i:=1;
1066 f_lazy_mmmi(10*f_returnOnefailIfIZero(), false);
1067 f_verdict(v_i==1);
1068 }
1069
1070 testcase tc_mmmi_4() runs on MyComp {
1071 v_i:=0;
1072 f_lazy_mmmi(10*f_returnOnePassIfIZero(), true);
1073 f_verdict(getverdict == pass);
1074 f_verdict(v_i==10);
1075 }
1076
1077 testcase tc_mmmi_5() runs on MyComp {
1078 v_i:=1;
1079 f_lazy_mmmi(10*f_returnOnefailIfIZero(), true);
1080 f_verdict(v_i==10);
1081 }
1082
1083 // **** With import *******
1084
1085 //==============================
1086 //Lazy calls
1087 //==============================
1088
1089 //basic behavior for integer arg expression:
1090 testcase tc_Ai_1() runs on MyComp {
1091 f_lazy_Ai(2+3*4, true);
1092 if(v_i==14) {setverdict(pass)} else {setverdict(fail)};
1093
1094 }
1095
1096 testcase tc_Ai_2() runs on MyComp {
1097 f_lazy_Ai(f_fail(), false);
1098 f_verdict(v_i==0);
1099 }
1100
1101 //The goal of this testcase
1102 //to test if expression is not evaluated if the condition is false
1103 testcase tc_Ai_3() runs on MyComp {
1104 v_i:=0;
1105 f_lazy_Ai(10*f_returnOnefailIfIZero(), false);
1106 f_verdict(v_i==0);
1107 }
1108
1109 //The goal of this testcase
1110 //to test if expression is not evaluated if the condition is false
1111 testcase tc_Ai_3a() runs on MyComp {
1112 v_i:=1;
1113 f_lazy_Ai(10*f_returnOnefailIfIZero(), false);
1114 f_verdict(v_i==1);
1115 }
1116
1117 testcase tc_Ai_4() runs on MyComp {
1118 v_i:=0;
1119 f_lazy_Ai(10*f_returnOnePassIfIZero(), true);
1120 f_verdict(getverdict == pass);
1121 f_verdict(v_i==10);
1122 }
1123
1124 testcase tc_Ai_5() runs on MyComp {
1125 v_i:=1;
1126 f_lazy_Ai(10*f_returnOnefailIfIZero(), true);
1127 f_verdict(v_i==10);
1128 }
1129
1130 //=================
1131 //Lazy calls lazy
1132 //=================
1133 //basic behavior for integer arg expression:
1134 testcase tc_AAi_1() runs on MyComp {
1135 f_lazy_AAi(2+3*4, true);
1136 if(v_i==14) {setverdict(pass)} else {setverdict(fail)};
1137
1138 }
1139
1140 testcase tc_AAi_2() runs on MyComp {
1141 f_lazy_AAi(f_fail(), false);
1142 f_verdict(v_i==0);
1143 }
1144
1145 //The goal of this testcase
1146 //to test if expression is not evaluated if the condition is false
1147 testcase tc_AAi_3() runs on MyComp {
1148 v_i:=0;
1149 f_lazy_AAi(10*f_returnOnefailIfIZero(), false);
1150 f_verdict(v_i==0);
1151 }
1152
1153 //The goal of this testcase
1154 //to test if expression is not evaluated if the condition is false
1155 testcase tc_AAi_3a() runs on MyComp {
1156 v_i:=1;
1157 f_lazy_AAi(10*f_returnOnefailIfIZero(), false);
1158 f_verdict(v_i==1);
1159 }
1160
1161 testcase tc_AAi_4() runs on MyComp {
1162 v_i:=0;
1163 f_lazy_AAi(10*f_returnOnePassIfIZero(), true);
1164 f_verdict(getverdict == pass);
1165 f_verdict(v_i==10);
1166 }
1167
1168 testcase tc_AAi_5() runs on MyComp {
1169 v_i:=1;
1170 f_lazy_AAi(10*f_returnOnefailIfIZero(), true);
1171 f_verdict(v_i==10);
1172 }
1173
1174 //basic behavior for integer arg expression:
1175 testcase tc_ABi_1() runs on MyComp {
1176 f_lazy_ABi(2+3*4, true);
1177 if(v_i==14) {setverdict(pass)} else {setverdict(fail)};
1178
1179 }
1180
1181 testcase tc_ABi_2() runs on MyComp {
1182 f_lazy_ABi(f_fail(), false);
1183 f_verdict(v_i==0);
1184 }
1185
1186 //The goal of this testcase
1187 //to test if expression is not evaluated if the condition is false
1188 testcase tc_ABi_3() runs on MyComp {
1189 v_i:=0;
1190 f_lazy_ABi(10*f_returnOnefailIfIZero(), false);
1191 f_verdict(v_i==0);
1192 }
1193
1194 //The goal of this testcase
1195 //to test if expression is not evaluated if the condition is false
1196 testcase tc_ABi_3a() runs on MyComp {
1197 v_i:=1;
1198 f_lazy_ABi(10*f_returnOnefailIfIZero(), false);
1199 f_verdict(v_i==1);
1200 }
1201
1202 testcase tc_ABi_4() runs on MyComp {
1203 v_i:=0;
1204 f_lazy_ABi(10*f_returnOnePassIfIZero(), true);
1205 f_verdict(getverdict == pass);
1206 f_verdict(v_i==10);
1207 }
1208
1209 testcase tc_ABi_5() runs on MyComp {
1210 v_i:=1;
1211 f_lazy_ABi(10*f_returnOnefailIfIZero(), true);
1212 f_verdict(v_i==10);
1213 }
1214
1215 //mixed
1216
1217 //basic behavior for integer arg expression:
1218 testcase tc_mABi_1() runs on MyComp {
1219 v_i:=1;
1220 var boolean b:=true;
1221 var integer i:=1;
1222 var float f:= 1.0;
1223 var bitstring bs:='1'B;
1224 var octetstring os:='55'O;
1225 var hexstring hs:='F'H;
1226 var charstring cs:="a";
1227 var R r:= { i:=1, f:=1.0}
1228 f_lazy_mABi(i+float2int(f)+bit2int(bs)+oct2int(os)+hex2int(hs)+char2int(cs)+r.i+float2int(r.f)+f_returnOneWithCounterIncr(), true);
1229 log(v_i);
1230 log(v_numberOfCalls);
1231 if(v_i==88+15+97+2+1 and i==1 and b==true and f==1.0 and bs=='1'B and os=='55'O and hs=='F'H and cs=="a" and v_numberOfCalls==1) {setverdict(pass)} else {setverdict(fail)};
1232 }
1233
1234testcase tc_mABi_2() runs on MyComp {
1235 v_i:=1;
1236 var boolean b:=true;
1237 var integer i:=1;
1238 var float f:= 1.0;
1239 var bitstring bs:='1'B;
1240 var octetstring os:='55'O;
1241 var hexstring hs:='F'H;
1242 var charstring cs:="a";
1243 var R r:= { i:=1, f:=1.0}
1244 f_lazy_mABi(i+float2int(f)+bit2int(bs)+oct2int(os)+hex2int(hs)+char2int(cs)+r.i+float2int(r.f)+f_returnOneWithCounterIncr(), false);
1245 if(v_i==1 and i==1 and b==true and f==1.0 and bs=='1'B and os=='55'O and hs=='F'H and cs=="a" and v_numberOfCalls==0) {setverdict(pass)} else {setverdict(fail)};
1246 }
1247
1248
1249 //The goal of this testcase
1250 //to test if expression is not evaluated if the condition is false
1251 testcase tc_mABi_3() runs on MyComp {
1252 v_i:=0;
1253 f_lazy_mABi(10*f_returnOnefailIfIZero(), false);
1254 f_verdict(v_i==0);
1255 }
1256
1257 //The goal of this testcase
1258 //to test if expression is not evaluated if the condition is false
1259 testcase tc_mABi_3a() runs on MyComp {
1260 v_i:=1;
1261 f_lazy_mABi(10*f_returnOnefailIfIZero(), false);
1262 f_verdict(v_i==1);
1263 }
1264
1265 testcase tc_mABi_4() runs on MyComp {
1266 v_i:=0;
1267 f_lazy_mABi(10*f_returnOnePassIfIZero(), true);
1268 f_verdict(getverdict == pass);
1269 f_verdict(v_i==10);
1270 }
1271
1272 testcase tc_mABi_5() runs on MyComp {
1273 v_i:=1;
1274 f_lazy_mABi(10*f_returnOnefailIfIZero(), true);
1275 f_verdict(v_i==10);
1276 }
1277
1278 //==== Lazy called in function ======
1279
1280 //not lazy function calls lazy function in main
1281 testcase tc_fmi_1() runs on MyComp {
1282 f_fmi_1();
1283 }
1284
1285 testcase tc_fmi_2() runs on MyComp {
1286 f_fmi_2();
1287 }
1288
1289 testcase tc_fmi_3() runs on MyComp {
1290 f_fmi_3();
1291 }
1292
1293 testcase tc_fmi_4() runs on MyComp {
1294 f_fmi_4();
1295 }
1296
1297 testcase tc_fmi_5() runs on MyComp {
1298 f_fmi_5();
1299 }
1300
1301 //not lazy function calls lazy function in imported module A
1302 testcase tc_fAi_1() runs on MyComp {
1303 f_fAi_1();
1304 }
1305
1306 testcase tc_fAi_2() runs on MyComp {
1307 f_fAi_2();
1308 }
1309
1310 testcase tc_fAi_3() runs on MyComp {
1311 f_fAi_3();
1312 }
1313
1314 testcase tc_fAi_4() runs on MyComp {
1315 f_fAi_4();
1316 }
1317
1318 testcase tc_fAi_5() runs on MyComp {
1319 f_fAi_5();
1320 }
1321
1322}//g_lazy_integer_arg_tc
1323
1324
1325group g_lazy_float_arg_tc {
1326 // Without import
1327 //basic behavior for float arg expression:
1328 testcase tc_mf_1() runs on MyComp {
1329 f_lazy_mf(2.1+3.5*4.4, true);
1330 if(v_f==2.1+3.5*4.4) {setverdict(pass)} else {setverdict(fail)};
1331 }
1332
1333
1334 //The goal of this testcase
1335 //to test if expression is not evaluated if the condition is false
1336 testcase tc_mf_3() runs on MyComp {
1337 v_f:=0.0;
1338 v_i:=0;
1339 f_lazy_mf(10.0*int2float(f_returnOnefailIfIZero()), false);
1340 f_verdict(v_f==0.0);
1341 }
1342
1343 //The goal of this testcase
1344 //to test if expression is not evaluated if the condition is false
1345 testcase tc_mf_3a() runs on MyComp {
1346 v_i:=1;
1347 f_lazy_mf(10.0*int2float(f_returnOnefailIfIZero()), false);
1348 f_verdict(v_f==0.0);
1349 }
1350
1351 testcase tc_mf_4() runs on MyComp {
1352 v_i:=0;
1353 f_lazy_mf(10.0*int2float(f_returnOnePassIfIZero()), true);
1354 f_verdict(getverdict == pass);
1355 f_verdict(v_f==10.0);
1356 }
1357
1358 testcase tc_mf_5() runs on MyComp {
1359 v_i:=1;
1360 f_lazy_mf(10.0*int2float(f_returnOnefailIfIZero()), true);
1361 f_verdict(v_f==10.0);
1362 }
1363
1364 //================
1365 // lazy calls lazy
1366 //================
1367
1368 // Without import
1369 //basic behavior for float arg expression,
1370 testcase tc_mmf_1() runs on MyComp {
1371 v_f:=0.0;
1372 f_lazy_mmf(2.1+3.5*4.4, true);
1373 if(v_f==2.1+3.5*4.4) {setverdict(pass)} else {setverdict(fail)};
1374 }
1375
1376
1377 //The goal of this testcase
1378 //to test if expression is not evaluated if the condition is false
1379 testcase tc_mmf_3() runs on MyComp {
1380 v_f:=0.0;
1381 v_i:=0;
1382 f_lazy_mmf(10.0*int2float(f_returnOnefailIfIZero()), false);
1383 f_verdict(v_f==0.0 and v_numberOfCalls==0);
1384 }
1385
1386 //The goal of this testcase
1387 //to test if expression is not evaluated if the condition is false
1388 testcase tc_mmf_3a() runs on MyComp {
1389 v_i:=1;
1390 f_lazy_mmf(10.0*int2float(f_returnOnefailIfIZero()), false);
1391 f_verdict(v_f==0.0 and v_numberOfCalls==0);
1392 }
1393
1394 testcase tc_mmf_4() runs on MyComp {
1395 v_i:=0;
1396 f_lazy_mmf(10.0*int2float(f_returnOnePassIfIZero()), true);
1397 f_verdict(getverdict == pass);
1398 f_verdict(v_f==10.0 and v_numberOfCalls==1);
1399 }
1400
1401 testcase tc_mmf_5() runs on MyComp {
1402 v_i:=1;
1403 f_lazy_mmf(10.0*int2float(f_returnOnefailIfIZero()), true);
1404 f_verdict(v_f==10.0 and v_numberOfCalls==1);
1405 }
1406 // the lazy arg is not the first arg:
1407 testcase tc_mmf_6() runs on MyComp {
1408 v_i:=1;
1409 f_lazy_mmf_2(true, 10.0*int2float(f_returnOnefailIfIZero()));
1410 log(v_f)
1411 log(v_numberOfCalls);
1412 f_verdict(v_f==10.0 and v_numberOfCalls==1);
1413 }
1414
1415 // f_lazy_mi_3 uses expression more than once
1416 //expression shall be evaluated only once
1417 testcase tc_mmf_7() runs on MyComp {
1418 v_i:=1;
1419 f_lazy_mmf(10.0*int2float(f_returnOneWithCounterIncr()),true);
1420 f_verdict(v_f==10.0 and v_numberOfCalls==1);
1421 }
1422
1423 // The first lazy arg is located in function
1424 testcase tc_fmf_1() runs on MyComp {
1425 f_mf_1();
1426 }
1427
1428
1429 //The goal of this testcase
1430 //to test if expression is not evaluated if the condition is false
1431 testcase tc_fmf_3() runs on MyComp {
1432 f_mf_3()
1433 }
1434
1435 //The goal of this testcase
1436 //to test if expression is not evaluated if the condition is false
1437 testcase tc_fmf_3a() runs on MyComp {
1438 f_mf_3a();
1439 }
1440
1441 testcase tc_fmf_4() runs on MyComp {
1442 f_mf_4();
1443 }
1444
1445 testcase tc_fmf_5() runs on MyComp {
1446 f_mf_5();
1447 }
1448
1449
1450}
1451group g_lazy_charstring_arg_tc {
1452
1453 testcase tc_mc_1() runs on MyComp {
1454 f_lazy_mc("Haliho",true);
1455 f_verdict(match(v_c,"Haliho") and v_numberOfCalls==0);
1456 }
1457
1458 testcase tc_mc_1b() runs on MyComp {
1459 f_lazy_mc(f_returnHelloPassWithZero(),true);
1460 log(v_c);
1461 log(v_numberOfCalls);
1462 log(match(v_c,"Hello"));
1463 f_verdict(match(v_c,"Hello") and v_numberOfCalls==1);
1464 }
1465
1466 testcase tc_mc_2() runs on MyComp {
1467 f_lazy_mc("Hi "&f_returnHelloPassWithZero(),false);
1468 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1469 }
1470
1471 // charstring value testcases
1472 testcase tc_mc_1_in() runs on MyComp {
1473 v_c:="";
1474 var boolean b:=true;
1475 var integer i:=1;
1476 var float f:= 1.0;
1477 var bitstring bs:='1'B;
1478 var octetstring os:='55'O;
1479 var hexstring hs:='F'H;
1480 var charstring cs:="a";
1481 var MyRec rec:= { i:=1, roi:={1,2},b:=true }
1482 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs(b)&" "&f_in_i_inc_retcs(i)&" "&
1483 f_in_f_inc_retcs(f)&" "&f_in_bs_4x_retcs(bs)&" "&f_in_os_256x_retcs(os)&" "&
1484 f_in_hs_16x_retcs(hs)&" "&f_in_cs_b_retcs(cs)&" "&f_in_port_retcs(PCO)&" "&f_in_b_inv_retcs(rec.b)&" "&f_in_i_inc_retcs(rec.i),true);
1485 log(v_c);
1486 log(v_numberOfCalls);
1487 log(match(v_c,"Hello false 2 2.000000 100 5500 F0 b"));
1488 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b port PCO false 2") and v_numberOfCalls==1);
1489 }
1490
1491 // this testcase aims to check if parameters can be passed to the lazy expression
1492 testcase tc_mc_par_1_in() runs on MyComp {
1493 v_c:="";
1494 var boolean b:=true;
1495 var integer i:=1;
1496 var float f:= 1.0;
1497 var bitstring bs:='1'B;
1498 var octetstring os:='55'O;
1499 var hexstring hs:='F'H;
1500 var charstring cs:="a";
1501 var MyRec rec:= { i:=1, roi:={1,2},b:=true};
1502
1503 f_mc_wrapper_in(b,i,f,bs,os,hs,cs,rec,true);
1504
1505 log(v_c);
1506 log(v_numberOfCalls);
1507 log( match(v_c,"Hello false 2 2.000000 100 5500 F0 b port PCO false 2"));
1508 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b port PCO false 2") and v_numberOfCalls==1);
1509 }
1510
1511 testcase tc_mc_2_in() runs on MyComp {
1512 v_c:="";
1513 var boolean b:=true;
1514 var integer i:=1;
1515 var float f:= 1.0;
1516 var bitstring bs:='1'B;
1517 var octetstring os:='55'O;
1518 var hexstring hs:='F'H;
1519 var charstring cs:="a";
1520 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs(b)&" "&f_in_i_inc_retcs(i)&" "&
1521 f_in_f_inc_retcs(f)&" "&f_in_bs_4x_retcs(bs)&" "&f_in_os_256x_retcs(os)&" "&
1522 f_in_hs_16x_retcs(hs)&" "&f_in_cs_b_retcs(cs),false);
1523 log(v_c);
1524 log(v_numberOfCalls);
1525 log(match(v_c,"Hello false 2 2.000000 100 5500 F0 b"));
1526 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1527 }
1528
1529 // this testcase aims to check if parameters can be passed to the lazy expression
1530 testcase tc_mc_par_2_in() runs on MyComp {
1531 v_c:="";
1532 var boolean b:=true;
1533 var integer i:=1;
1534 var float f:= 1.0;
1535 var bitstring bs:='1'B;
1536 var octetstring os:='55'O;
1537 var hexstring hs:='F'H;
1538 var charstring cs:="a";
1539 var MyRec rec:= { i:=1, roi:={1,2},b:=true};
1540
1541 f_mc_wrapper_in(b,i,f,bs,os,hs,cs,rec,false);
1542
1543 log(v_c);
1544 log(v_numberOfCalls);
1545 log( match(v_c,""));
1546 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1547 }
1548 testcase tc_mc_1_inout() runs on MyComp {
1549 v_c:="";
1550 var boolean b:=true;
1551 var integer i:=1;
1552 var float f:= 1.0;
1553 var bitstring bs:='1'B;
1554 var octetstring os:='55'O;
1555 var hexstring hs:='F'H;
1556 var charstring cs:="a";
1557 var MyRec rec:= { i:=1, roi:={1,2},b:=true }
1558 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_inout_b_inv_retcs(b)&" "&f_inout_i_inc_retcs(i)&" "&
1559 f_inout_f_inc_retcs(f)&" "&f_inout_bs_4x_retcs(bs)&" "&f_inout_os_256x_retcs(os)&" "&
1560 f_inout_hs_16x_retcs(hs)&" "&f_inout_cs_b_retcs(cs)&" "&f_inout_port_retcs(PCO)&" "&f_inout_b_inv_retcs(rec.b)&" "&f_inout_i_inc_retcs(rec.i),true);
1561 log(v_c);
1562 log(v_numberOfCalls);
1563 log(match(v_c,""));
1564 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b port PCO false 2") and v_numberOfCalls==1);
1565 }
1566
1567 testcase tc_mc_par_1_inout_in() runs on MyComp {
1568 v_c:="";
1569 var boolean b:=true;
1570 var integer i:=1;
1571 var float f:= 1.0;
1572 var bitstring bs:='1'B;
1573 var octetstring os:='55'O;
1574 var hexstring hs:='F'H;
1575 var charstring cs:="a";
1576 var MyRec rec:= { i:=1, roi:={1,2},b:=true};
1577
1578 f_mc_wrapper_inout_in(b,i,f,bs,os,hs,cs,rec,true);
1579
1580 log(v_c);
1581 log(v_numberOfCalls);
1582 log( match(v_c,"Hello false 2 2.000000 100 5500 F0 b port PCO false 2"));
1583 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b port PCO false 2") and v_numberOfCalls==1);
1584 }
1585
1586 testcase tc_mc_par_1_inout_inout() runs on MyComp {
1587 v_c:="";
1588 var boolean b:=true;
1589 var integer i:=1;
1590 var float f:= 1.0;
1591 var bitstring bs:='1'B;
1592 var octetstring os:='55'O;
1593 var hexstring hs:='F'H;
1594 var charstring cs:="a";
1595 var MyRec rec:= { i:=1, roi:={1,2},b:=true};
1596
1597 f_mc_wrapper_inout_inout(b,i,f,bs,os,hs,cs,rec,true);
1598
1599 log(v_c);
1600 log(v_numberOfCalls);
1601 log( match(v_c,"Hello false 2 2.000000 100 5500 F0 b port PCO false 2"));
1602 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b port PCO false 2") and v_numberOfCalls==1);
1603 }
1604 testcase tc_mc_2_inout() runs on MyComp {
1605 v_c:="";
1606 var boolean b:=true;
1607 var integer i:=1;
1608 var float f:= 1.0;
1609 var bitstring bs:='1'B;
1610 var octetstring os:='55'O;
1611 var hexstring hs:='F'H;
1612 var charstring cs:="a";
1613 var MyRec rec:= { i:=1, roi:={1,2},b:=true }
1614 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_inout_b_inv_retcs(b)&" "&f_inout_i_inc_retcs(i)&" "&
1615 f_inout_f_inc_retcs(f)&" "&f_inout_bs_4x_retcs(bs)&" "&f_inout_os_256x_retcs(os)&" "&
1616 f_inout_hs_16x_retcs(hs)&" "&f_inout_cs_b_retcs(cs)&" "&f_inout_port_retcs(PCO)&" "&f_inout_b_inv_retcs(rec.b)&" "&f_inout_i_inc_retcs(rec.i),false);
1617 log(v_c);
1618 log(v_numberOfCalls);
1619 log(match(v_c,"Hello false 2 2.000000 100 5500 F0 b port PCO"));
1620 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1621 }
1622
1623testcase tc_mc_par_2_inout_in() runs on MyComp {
1624 v_c:="";
1625 var boolean b:=true;
1626 var integer i:=1;
1627 var float f:= 1.0;
1628 var bitstring bs:='1'B;
1629 var octetstring os:='55'O;
1630 var hexstring hs:='F'H;
1631 var charstring cs:="a";
1632 var MyRec rec:= { i:=1, roi:={1,2},b:=true};
1633
1634 f_mc_wrapper_inout_in(b,i,f,bs,os,hs,cs,rec,false);
1635
1636 log(v_c);
1637 log(v_numberOfCalls);
1638 log( match(v_c,""));
1639 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1640 }
1641
1642 testcase tc_mc_par_2_inout_inout() runs on MyComp {
1643 v_c:="";
1644 var boolean b:=true;
1645 var integer i:=1;
1646 var float f:= 1.0;
1647 var bitstring bs:='1'B;
1648 var octetstring os:='55'O;
1649 var hexstring hs:='F'H;
1650 var charstring cs:="a";
1651 var MyRec rec:= { i:=1, roi:={1,2},b:=true};
1652
1653 f_mc_wrapper_inout_inout(b,i,f,bs,os,hs,cs,rec,false);
1654
1655 log(v_c);
1656 log(v_numberOfCalls);
1657 log( match(v_c,""));
1658 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1659 }
1660 testcase tc_mc_1_out() runs on MyComp {
1661 v_c:="";
1662 var boolean b:=true;
1663 var integer i:=1;
1664 var float f:= 1.0;
1665 var bitstring bs:='1'B;
1666 var octetstring os:='55'O;
1667 var hexstring hs:='F'H;
1668 var charstring cs:="a";
1669 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_out_b_inv_retcs(b)&" "&f_out_i_inc_retcs(i)&" "&
1670 f_out_f_inc_retcs(f)&" "&f_out_bs_4x_retcs(bs)&" "&f_out_os_256x_retcs(os)&" "&
1671 f_out_hs_16x_retcs(hs)&" "&f_out_cs_b_retcs(cs),true);
1672 log(v_c);
1673 log(v_numberOfCalls);
1674 log(match(v_c,"Hello false 2 2.000000 100 5500 F0 b"));
1675 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b") and v_numberOfCalls==1);
1676 }
1677
1678 testcase tc_mc_2_out() runs on MyComp {
1679 v_c:="";
1680 var boolean b:=true;
1681 var integer i:=1;
1682 var float f:= 1.0;
1683 var bitstring bs:='1'B;
1684 var octetstring os:='55'O;
1685 var hexstring hs:='F'H;
1686 var charstring cs:="a";
1687 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_out_b_inv_retcs(b)&" "&f_out_i_inc_retcs(i)&" "&
1688 f_out_f_inc_retcs(f)&" "&f_out_bs_4x_retcs(bs)&" "&f_out_os_256x_retcs(os)&" "&
1689 f_out_hs_16x_retcs(hs)&" "&f_out_cs_b_retcs(cs),false);
1690 log(v_c);
1691 log(v_numberOfCalls);
1692 log(match(v_c,"Hello 2 2.000000 100 5500 F0 b"));
1693 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1694 }
1695
1696 //==== charstring template testcases
1697 testcase tc_mc_1_in_t() runs on MyComp {
1698 v_c:="";
1699 var template boolean b:=true;
1700 var template integer i:=1;
1701 var template float f:= 1.0;
1702 var template bitstring bs:='1'B;
1703 var template octetstring os:='55'O;
1704 var template hexstring hs:='F'H;
1705 var template charstring cs:="a";
1706 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs_t(b)&" "&f_in_i_inc_retcs_t(i)&" "&
1707 f_in_f_inc_retcs_t(f)&" "&f_in_bs_4x_retcs_t(bs)&" "&f_in_os_256x_retcs_t(os)&" "&
1708 f_in_hs_16x_retcs_t(hs)&" "&f_in_cs_b_retcs_t(cs),true);
1709 log(v_c);
1710 log(v_numberOfCalls);
1711 log(match(v_c,"Hello false 2 2.000000 100 5500 F0 b"));
1712 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b") and v_numberOfCalls==1);
1713 }
1714
1715 testcase tc_mc_2_in_t() runs on MyComp {
1716 v_c:="";
1717 var template boolean b:=true;
1718 var template integer i:=1;
1719 var template float f:= 1.0;
1720 var template bitstring bs:='1'B;
1721 var template octetstring os:='55'O;
1722 var template hexstring hs:='F'H;
1723 var template charstring cs:="a";
1724 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs_t(b)&" "&f_in_i_inc_retcs_t(i)&" "&
1725 f_in_f_inc_retcs_t(f)&" "&f_in_bs_4x_retcs_t(bs)&" "&f_in_os_256x_retcs_t(os)&" "&
1726 f_in_hs_16x_retcs_t(hs)&" "&f_in_cs_b_retcs_t(cs),false);
1727 log(v_c);
1728 log(v_numberOfCalls);
1729 log(match(v_c,"Hello true 2 2.000000 100 5500 F0 b"));
1730 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1731 }
1732 testcase tc_mc_1_inout_t() runs on MyComp {
1733 v_c:="";
1734 var template boolean b:=true;
1735 var template integer i:=1;
1736 var template float f:= 1.0;
1737 var template bitstring bs:='1'B;
1738 var template octetstring os:='55'O;
1739 var template hexstring hs:='F'H;
1740 var template charstring cs:="a";
1741 var template MyRec rec:= { i:=1, roi:={1,2},b:=true };
1742 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs_t(b)&" "&f_inout_i_inc_retcs_t(i)&" "&
1743 f_inout_f_inc_retcs_t(f)&" "&f_inout_bs_4x_retcs_t(bs)&" "&f_inout_os_256x_retcs_t(os)&" "&
1744 f_inout_hs_16x_retcs_t(hs)&" "&f_inout_cs_b_retcs_t(cs)&" "&f_inout_b_inv_retcs_t(rec.b)&" "&f_inout_i_inc_retcs_t(rec.i),true);
1745 log(v_c);
1746 log(v_numberOfCalls);
1747 log(match(v_c,"Hello false 2 2.000000 100 5500 F0 b false 2"));
1748 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b false 2") and v_numberOfCalls==1);
1749 }
1750
1751 testcase tc_mc_2_inout_t() runs on MyComp {
1752 v_c:="";
1753 var template boolean b:=true;
1754 var template integer i:=1;
1755 var template float f:= 1.0;
1756 var template bitstring bs:='1'B;
1757 var template octetstring os:='55'O;
1758 var template hexstring hs:='F'H;
1759 var template charstring cs:="a";
1760 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs_t(b)&" "&f_inout_i_inc_retcs_t(i)&" "&
1761 f_inout_f_inc_retcs_t(f)&" "&f_inout_bs_4x_retcs_t(bs)&" "&f_inout_os_256x_retcs_t(os)&" "&
1762 f_inout_hs_16x_retcs_t(hs)&" "&f_inout_cs_b_retcs_t(cs),false);
1763 log(v_c);
1764 log(v_numberOfCalls);
1765 log(match(v_c,""));
1766 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1767 }
1768
1769 testcase tc_mc_1_out_t() runs on MyComp {
1770 v_c:="";
1771 var template boolean b:=true;
1772 var template integer i:=1;
1773 var template float f:= 1.0;
1774 var template bitstring bs:='1'B;
1775 var template octetstring os:='55'O;
1776 var template hexstring hs:='F'H;
1777 var template charstring cs:="a";
1778 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_out_b_inv_retcs_t(b)&" "&f_out_i_inc_retcs_t(i)&" "&
1779 f_out_f_inc_retcs_t(f)&" "&f_out_bs_4x_retcs_t(bs)&" "&f_out_os_256x_retcs_t(os)&" "&
1780 f_out_hs_16x_retcs_t(hs)&" "&f_out_cs_b_retcs_t(cs),true);
1781 log(v_c);
1782 log(v_numberOfCalls);
1783 log(match(v_c,"Hello false 2 2.000000 100 5500 F0 b"));
1784 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b") and v_numberOfCalls==1);
1785 }
1786
1787 testcase tc_mc_2_out_t() runs on MyComp {
1788 v_c:="";
1789 var template boolean b:=true;
1790 var template integer i:=1;
1791 var template float f:= 1.0;
1792 var template bitstring bs:='1'B;
1793 var template octetstring os:='55'O;
1794 var template hexstring hs:='F'H;
1795 var template charstring cs:="a";
1796 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_out_b_inv_retcs_t(b)&" "&f_out_i_inc_retcs_t(i)&" "&
1797 f_out_f_inc_retcs_t(f)&" "&f_out_bs_4x_retcs_t(bs)&" "&f_out_os_256x_retcs_t(os)&" "&
1798 f_out_hs_16x_retcs_t(hs)&" "&f_out_cs_b_retcs_t(cs),false);
1799 log(v_c);
1800 log(v_numberOfCalls);
1801 log(match(v_c,""));
1802 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1803 }
1804
1805 //const
1806 testcase tc_mc_const_1() runs on MyComp {
1807 v_c:="";
1808 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs_t(c_b)&" "&f_in_i_inc_retcs(c_i)&" "&
1809 f_in_f_inc_retcs(c_f)&" "&f_in_bs_4x_retcs(c_bs)&" "&f_in_os_256x_retcs(c_os)&" "&
1810 f_in_hs_16x_retcs(c_hs)&" "&f_in_cs_b_retcs(c_cs),true);
1811 log(v_c);
1812 log(v_numberOfCalls);
1813 //log(match(v_c,"Hello false 2 2.000000 100 5500 F0 b"));
1814 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b") and v_numberOfCalls==1);
1815 }
1816
1817 testcase tc_mc_const_2() runs on MyComp {
1818 v_c:="";
1819 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs_t(c_b)&" "&f_in_i_inc_retcs(c_i)&" "&
1820 f_in_f_inc_retcs(c_f)&" "&f_in_bs_4x_retcs(c_bs)&" "&f_in_os_256x_retcs(c_os)&" "&
1821 f_in_hs_16x_retcs(c_hs)&" "&f_in_cs_b_retcs(c_cs),false);
1822 log(v_c);
1823 log(v_numberOfCalls);
1824 //log(match(v_c,""));
1825 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1826 }
1827
1828
1829 //==== charstring template testcases
1830 testcase tc_mc_const_1_t() runs on MyComp {
1831 v_c:="";
1832 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs_t(t_b)&" "&f_in_i_inc_retcs_t(t_i)&" "&
1833 f_in_f_inc_retcs_t(t_f)&" "&f_in_bs_4x_retcs_t(t_bs)&" "&f_in_os_256x_retcs_t(t_os)&" "&
1834 f_in_hs_16x_retcs_t(t_hs)&" "&f_in_cs_b_retcs_t(t_cs),true);
1835 log(v_c);
1836 log(v_numberOfCalls);
1837 log(match(v_c,"Hello false 2 2.000000 100 5500 F0 b"));
1838 f_verdict(match(v_c,"Hello false 2 2.000000 100 5500 F0 b") and v_numberOfCalls==1);
1839 }
1840
1841 testcase tc_mc_const_2_t() runs on MyComp {
1842 v_c:="";
1843 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_in_b_inv_retcs_t(t_b)&" "&f_in_b_inv_retcs_t(t_b)&" "&f_in_i_inc_retcs_t(t_i)&" "&
1844 f_in_f_inc_retcs_t(t_f)&" "&f_in_bs_4x_retcs_t(t_bs)&" "&f_in_os_256x_retcs_t(t_os)&" "&
1845 f_in_hs_16x_retcs_t(t_hs)&" "&f_in_cs_b_retcs_t(t_cs),false);
1846 log(v_c);
1847 log(v_numberOfCalls);
1848 log(match(v_c,"Hello true 2 2.000000 100 5500 F0 b"));
1849 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1850 }
1851
1852 //===const2: rec, recof, array, set, setof, enum, union, anytype===
1853 testcase tc_mc_const2_1() runs on MyComp {
1854 log(log2str(c_myRec)," ",c_rocs," ",c_cs3);
1855 f_lazy_mc(f_returnHelloPassWithZero()&log2str(c_myRec)&log2str(c_rocs)&log2str(c_cs3)&log2str(c_set)&log2str(c_socs)&log2str(c_enum)&log2str(c_union),true);
1856 f_verdict(match(v_c,"Hello"&log2str(c_myRec)&log2str(c_rocs)&log2str(c_cs3)&log2str(c_set)&log2str(c_socs)&log2str(c_enum)&log2str(c_union)) and v_numberOfCalls==1);
1857 }
1858
1859 testcase tc_mc_const2_2() runs on MyComp {
1860 log(log2str(c_myRec)," ",c_rocs," ",c_cs3);
1861 f_lazy_mc(f_returnHelloPassWithZero()&log2str(c_myRec)&log2str(c_rocs)&log2str(c_cs3)&log2str(t_set)&log2str(t_socs)&log2str(t_enum)&log2str(c_union),false);
1862 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1863 }
1864
1865 testcase tc_mc_const2_1_t() runs on MyComp {
1866 log(log2str(t_myRec)," ",t_rocs," ",t_cs3, log2str(t_cs3)&log2str(t_set)&log2str(t_socs)&log2str(t_enum)&log2str(c_union));
1867 f_lazy_mc(f_returnHelloPassWithZero()&log2str(t_myRec)&log2str(t_rocs)&log2str(t_cs3)&log2str(t_set)&log2str(t_socs)&log2str(t_enum)&log2str(c_union),true);
1868 f_verdict(match(v_c,"Hello"&log2str(t_myRec)&log2str(t_rocs)&log2str(t_cs3)&log2str(t_set)&log2str(t_socs)&log2str(t_enum)&log2str(c_union)) and v_numberOfCalls==1);
1869 }
1870
1871 testcase tc_mc_const2_2_t() runs on MyComp {
1872 log(log2str(t_myRec)," ",t_rocs," ",t_cs3," ",t_set," ",t_socs," ",t_enum," ",t_union);
1873 f_lazy_mc(f_returnHelloPassWithZero()&log2str(t_myRec)&log2str(t_rocs)&log2str(t_cs3)&log2str(t_set)&log2str(t_socs)&log2str(t_enum)&log2str(c_union),false);
1874 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1875 }
1876
1877 testcase tc_mc_asn1_1() runs on MyComp {
1878 f_lazy_mc(f_returnHelloPassWithZero()&log2str(c_asn1rec)&log2str(myASNrec),true);
1879 f_verdict(match(v_c,"Hello"&log2str(c_asn1rec)&log2str(myASNrec)) and v_numberOfCalls==1);
1880 log(v_c);
1881 }
1882
1883 testcase tc_mc_asn1_2() runs on MyComp {
1884 f_lazy_mc(f_returnHelloPassWithZero()&log2str(c_asn1rec)&log2str(myASNrec),false);
1885 log(v_c);
1886 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1887 }
1888
1889 testcase tc_mc_asn1_1_inout() runs on MyComp {
1890 v_c:="";
1891 var MyASNRecord asnrec := { b:=true,i:=1,r:=1.0,bs:='1'B, os:='FF'O, cs:="a"}
1892 var MyASNUnion asnunion := { i:= 1};
1893 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_inout_b_inv_retcs(asnrec.b)&" "&f_inout_i_inc_retcs(asnrec.i)&" "&
1894 f_inout_f_inc_retcs(asnrec.r)&" "&f_inout_bs_4x_retcs(asnrec.bs)&" "&f_inout_os_256x_retcs(asnrec.os)&" "&
1895 f_inout_cs_b_retcs(asnrec.cs)&" "&f_inout_i_inc_retcs(asnunion.i),true);
1896 log(v_c);
1897 log(v_numberOfCalls);
1898 log(match(v_c,"Hello false 2 2.000000 100 FF00 b 2"));
1899 f_verdict(match(v_c,"Hello false 2 2.000000 100 FF00 b 2") and v_numberOfCalls==1);
1900 }
1901
1902 testcase tc_mc_asn1_2_inout() runs on MyComp {
1903 v_c:="";
1904 var MyASNRecord asnrec := { b:=true,i:=1,r:=1.0,bs:='1'B, os:='FF'O, cs:="a"}
1905 var MyASNUnion asnunion := { i:= 1};
1906 f_lazy_mc(f_returnHelloPassWithZero()&" "&f_inout_b_inv_retcs(asnrec.b)&" "&f_inout_i_inc_retcs(asnrec.i)&" "&
1907 f_inout_f_inc_retcs(asnrec.r)&" "&f_inout_bs_4x_retcs(asnrec.bs)&" "&f_inout_os_256x_retcs(asnrec.os)&" "&
1908 f_inout_cs_b_retcs(asnrec.cs)&" "&f_inout_i_inc_retcs(asnunion.i),false);
1909 log(v_c);
1910 log(v_numberOfCalls);
1911 //log(match(v_c,""));
1912 f_verdict(match(v_c,"") and v_numberOfCalls==0);
1913 }
1914
1915}//g_lazy_charstring_arg_tc
1916
1917group g_lazy_boolean_arg_tc {
1918
1919}
1920
1921group g_lazy_rec_arg_tc {
1922
1923 testcase tc_mrec_1() runs on MyComp {
1924 var MyRec vl_myRec:=c_myRec;
1925 vl_myRec.i:= 2*vl_myRec.i;
1926 f_lazy_mrec(vl_myRec, true);
1927 f_verdict(match(vl_myRec,v_rec) and v_numberOfCalls==0);
1928 }
1929
1930 testcase tc_mrec_2() runs on MyComp {
1931 f_lazy_mrec(f_returnRec(1+v_rec.i,v_rec.roi,v_rec.b), true)
1932 f_verdict( match(v_rec,{11,{11,12},true}) and v_numberOfCalls==1);
1933 }
1934
1935 testcase tc_mrec_3() runs on MyComp {
1936 f_lazy_mrec(f_returnRec(1+v_rec.i,v_rec.roi,v_rec.b), false)
1937 f_verdict( match(v_rec,c_myRec) and v_numberOfCalls==0);
1938 }
1939
1940
1941}//g_lazy_rec_arg_tc
1942
1943group g_lazy_template_tc {
1944
1945 //testcase calls template with lazy arg
1946
1947 testcase tc_template_1() runs on MyComp {
1948 var template MyRec vl_myRec;
1949 vl_myRec:=t_lazy_rec(10*f_returnOnePassIfIZero(), {1,2}, ?);
1950 f_verdict(getverdict == pass);
1951 f_verdict(match({10,{1,2},true},vl_myRec));
1952 f_verdict(v_numberOfCalls==1);
1953 }
1954
1955 testcase tc_template_1a() runs on MyComp {
1956 var template MyRec vl_myRec;
1957 vl_myRec:=t_lazy_rec(10*f_returnOnePassIfIZero(), {f_returnOnePassIfIZero(),2}, ?);
1958 f_verdict(getverdict == pass);
1959 f_verdict(match({10,{1,2},true},vl_myRec));
1960 f_verdict(v_numberOfCalls==2);
1961 }
1962
1963 testcase tc_template_2() runs on MyComp {
1964 f_verdict(match({10,{1,2},true},t_lazy_rec(10*f_returnOnePassIfIZero(), {1,2}, ?)));
1965 f_verdict(v_numberOfCalls==1);
1966 }
1967
1968 testcase tc_template_3() runs on MyComp {
1969 f_verdict(true or match({10,{1,2},true},t_lazy_rec(10*f_returnOnePassIfIZero(), {1,2}, ?)));
1970 log(v_numberOfCalls);
1971 f_verdict(v_numberOfCalls==0);
1972 }
1973
1974 //control without lazy:
1975 testcase tc_template_4() runs on MyComp {
1976 f_verdict(true or match({10,{1,2},true},t_rec(10*f_returnOnePassIfIZero(), {1,2}, ?)));
1977 f_verdict(v_numberOfCalls==0);
1978 }
1979
1980 //not used first arg
1981 testcase tc_template_5() runs on MyComp {
1982 f_verdict(match({1,{1,2},true},t_lazy_rec1(10*f_returnOnePassIfIZero(), {1,2}, ?)));
1983 log(v_numberOfCalls);
1984 f_verdict(v_numberOfCalls==0);
1985 }
1986
1987
1988 //function calls template with lazy arg
1989 //dyn template ?
1990
1991}//g_lazy_template_tc
1992
1993group g_lazy_altstep_tc {
1994 testcase tc_altstep_mi_1() runs on MyComp {
1995 v_i:=0;
1996 as_lazy_mi(10*f_returnOneWithCounterIncr()*f_returnOnePassIfIZero(),true);
1997 f_verdict(getverdict == pass);
1998 f_verdict(v_i==10 and v_numberOfCalls==2);
1999 }
2000
2001
2002 testcase tc_altstep_mi_2() runs on MyComp {
2003 v_i:=1;
2004 as_lazy_mi(10*f_returnOneWithCounterIncr()*f_returnOnePassIfIZero(),true);
2005 f_verdict(getverdict == none);
2006 f_verdict(v_i==10 and v_numberOfCalls==2);
2007 }
2008
2009 //if the evalFlag is false, the expression must not evaluated
2010 testcase tc_altstep_mi_3() runs on MyComp {
2011 v_i:=0;
2012 as_lazy_mi(10*f_returnOneWithCounterIncr()*f_returnOnePassIfIZero(),false);
2013 f_verdict(getverdict == none);
2014 f_verdict(v_i==0 and v_numberOfCalls==0);
2015 }
2016
2017 testcase tc_altstep_Ai_1() runs on MyComp {
2018 as_lazy_Ai(10*f_returnOneWithCounterIncr()*f_returnOnePassIfIZero(),true);
2019 f_verdict(getverdict == pass );
2020 f_verdict(v_i==10 and v_numberOfCalls==2);
2021 }
2022
2023 testcase tc_altstep_Ai_2() runs on MyComp {
2024 v_i:=1;
2025 as_lazy_Ai(10*f_returnOneWithCounterIncr()*f_returnOnePassIfIZero(),true);
2026 f_verdict(getverdict == none );
2027 f_verdict(v_i==10 and v_numberOfCalls==2);
2028 }
2029 //if the evalFlag is false, the expression must not evaluated
2030 testcase tc_altstep_Ai_3() runs on MyComp {
2031 v_i:=0;
2032 as_lazy_Ai(10*f_returnOneWithCounterIncr()*f_returnOnePassIfIZero(),false);
2033 f_verdict(getverdict == none );
2034 f_verdict(v_i==0 and v_numberOfCalls==0);
2035 }
2036
2037 testcase tc_altstep_ABi_1() runs on MyComp {
2038 as_lazy_ABi(10*f_returnOneWithCounterIncr()*f_returnOnePassIfIZero(),true);
2039 f_verdict(getverdict == pass );
2040 f_verdict(v_i==10 and v_numberOfCalls==2);
2041 }
2042 //if the evalFlag is false, the expression must not evaluated
2043 testcase tc_altstep_ABi_2() runs on MyComp {
2044 v_i:=1;
2045 as_lazy_ABi(10*f_returnOneWithCounterIncr()*f_returnOnePassIfIZero(),true);
2046 f_verdict(getverdict == none );
2047 f_verdict(v_i==10 and v_numberOfCalls==2);
2048 }
2049 testcase tc_altstep_ABi_3() runs on MyComp {
2050 v_i:=0;
2051 as_lazy_ABi(10*f_returnOneWithCounterIncr()*f_returnOnePassIfIZero(),false);
2052 f_verdict(getverdict == none );
2053 f_verdict(v_i==0 and v_numberOfCalls==0);
2054 }
2055
2056 testcase tc_altstep_fi_1() runs on MyComp {
2057 v_i:=0;
2058 as_lazy_mf(10.0*int2float(f_returnOneWithCounterIncr()*f_returnOnePassIfIZero()),true);
2059 f_verdict(getverdict == pass);
2060 f_verdict(v_f==10.0 and v_numberOfCalls==2);
2061 }
2062
2063
2064 testcase tc_altstep_fi_2() runs on MyComp {
2065 v_i:=1;
2066 as_lazy_mf(10.0*int2float(f_returnOneWithCounterIncr()*f_returnOnePassIfIZero()),true);
2067 f_verdict(getverdict == none);
2068 f_verdict(v_f==10.0 and v_numberOfCalls==2);
2069 }
2070
2071 //if the evalFlag is false, the expression must not evaluated
2072 testcase tc_altstep_fi_3() runs on MyComp {
2073 v_i:=0;
2074 as_lazy_mf(10.0*int2float(f_returnOneWithCounterIncr()*f_returnOnePassIfIZero()),false);
2075 f_verdict(getverdict == none);
2076 f_verdict(v_f==0.0 and v_numberOfCalls==0);
2077 }
2078
2079}//g_lazy_altstep_tc
2080
2081control{
2082 log("Control part started");
2083 //integer
2084 execute(tc_mi_1());
2085 execute(tc_mi_2());
2086 execute(tc_mi_3());
2087 execute(tc_mi_4());
2088 execute(tc_mi_5());
2089 execute(tc_mi_6());
2090 execute(tc_mi_7());
2091
2092 execute(tc_mi_1_in());
2093 execute(tc_mi_2_in());
2094 execute(tc_mi_1_inout());
2095 execute(tc_mi_2_inout());
2096 execute(tc_mi_1_in_t());
2097 execute(tc_mi_2_in_t());
2098 execute(tc_mi_1_inout_t());
2099 execute(tc_mi_2_inout_t());
2100 execute(tc_mi_1_out_t());
2101 execute(tc_mi_2_out_t());
2102
2103 execute(tc_mmi_1());
2104 execute(tc_mmi_1b());
2105 execute(tc_mmi_2());
2106 execute(tc_mmi_3());
2107 execute(tc_mmi_4());
2108 execute(tc_mmi_5());
2109
2110 execute(tc_mmmi_1());
2111 execute(tc_mmmi_1b());
2112 execute(tc_mmmi_2());
2113 execute(tc_mmmi_3());
2114 execute(tc_mmmi_4());
2115 execute(tc_mmmi_5());
2116
2117 execute(tc_Ai_1());
2118 execute(tc_Ai_2());
2119 execute(tc_Ai_3());
2120 execute(tc_Ai_4());
2121 execute(tc_Ai_5());
2122
2123 execute(tc_AAi_1());
2124 execute(tc_AAi_2());
2125 execute(tc_AAi_3());
2126 execute(tc_AAi_4());
2127 execute(tc_AAi_5());
2128
2129 execute(tc_ABi_1());
2130 execute(tc_ABi_2());
2131 execute(tc_ABi_3());
2132 execute(tc_ABi_4());
2133 execute(tc_ABi_5());
2134
2135 execute(tc_mABi_1());
2136 execute(tc_mABi_2());
2137 execute(tc_mABi_3());
2138 execute(tc_mABi_4());
2139 execute(tc_mABi_5());
2140
2141 execute(tc_fmi_1());
2142 execute(tc_fmi_2());
2143 execute(tc_fmi_3());
2144 execute(tc_fmi_4());
2145 execute(tc_fmi_5());
2146
2147 execute(tc_fAi_1());
2148 execute(tc_fAi_2());
2149 execute(tc_fAi_3());
2150 execute(tc_fAi_4());
2151 execute(tc_fAi_5());
2152
2153 //float
2154 execute(tc_mf_1());
2155 execute(tc_mf_3());
2156 execute(tc_mf_3a());
2157 execute(tc_mf_4());
2158 execute(tc_mf_5());
2159
2160
2161 execute(tc_mmf_1());
2162 execute(tc_mmf_3());
2163 execute(tc_mmf_3a());
2164 execute(tc_mmf_4());
2165 execute(tc_mmf_5());
2166 execute(tc_mmf_6());
2167 execute(tc_mmf_7());
2168
2169 execute(tc_fmf_1());
2170 execute(tc_fmf_3());
2171 execute(tc_fmf_3a());
2172 execute(tc_fmf_4());
2173 execute(tc_fmf_5());
2174
2175 //charstring
2176 execute(tc_mc_1());
2177 execute(tc_mc_1b());
2178 execute(tc_mc_2());
2179 execute(tc_mc_1_in());
2180 execute(tc_mc_par_1_in());
2181 execute(tc_mc_2_in());
2182 execute(tc_mc_par_2_in());
2183 execute(tc_mc_1_inout());
2184 execute(tc_mc_par_1_inout_in());
2185 execute(tc_mc_par_1_inout_inout());
2186 execute(tc_mc_2_inout());
2187 execute(tc_mc_par_2_inout_in());
2188 execute(tc_mc_par_2_inout_inout());
2189 execute(tc_mc_1_out());
2190 execute(tc_mc_2_out());
2191 execute(tc_mc_1_in_t());
2192 execute(tc_mc_2_in_t());
2193 execute(tc_mc_1_inout_t());
2194 execute(tc_mc_2_inout_t());
2195 execute(tc_mc_1_out_t());
2196 execute(tc_mc_2_out_t());
2197
2198 execute(tc_mc_const_1());
2199 execute(tc_mc_const_2());
2200 execute(tc_mc_const_1_t());
2201 execute(tc_mc_const_2_t());
2202 execute(tc_mc_const2_1());
2203 execute(tc_mc_const2_2());
2204 execute(tc_mc_const2_1_t());
2205 execute(tc_mc_const2_2_t());
2206 execute(tc_mc_asn1_1());
2207 execute(tc_mc_asn1_2());
2208 execute(tc_mc_asn1_1_inout());
2209 execute(tc_mc_asn1_2_inout());
2210
2211 //record
2212 execute(tc_mrec_1());
2213 execute(tc_mrec_2());
2214 execute(tc_mrec_3());
2215
2216 //template
2217 execute(tc_template_1());
2218 execute(tc_template_1a());
2219 execute(tc_template_2());
2220 execute(tc_template_3());
2221 execute(tc_template_4());
2222 execute(tc_template_5());
2223 //altstep
2224 execute(tc_altstep_mi_1());
2225 execute(tc_altstep_mi_2());
2226 execute(tc_altstep_mi_3());
2227 execute(tc_altstep_Ai_1());
2228 execute(tc_altstep_Ai_2());
2229 execute(tc_altstep_Ai_3());
2230 execute(tc_altstep_ABi_1());
2231 execute(tc_altstep_ABi_2());
2232 execute(tc_altstep_ABi_3());
2233 execute(tc_altstep_fi_1());
2234 execute(tc_altstep_fi_2());
2235 execute(tc_altstep_fi_3());
2236
2237}
2238
2239
2240
2241}
This page took 0.100488 seconds and 5 git commands to generate.