50101_classes.script 52.9 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
.******************************************************************************
.* Copyright (c) ETSI 2020.
.*
.* This file is subject to copyrights owned by ETSI. Non-exclusive permission 
.* is hereby granted, free of charge, to copy, reproduce and amend this file 
.* under the following conditions: It is provided "as is", without warranty of any 
.* kind, expressed or implied. 
.*
.* ETSI shall never be liable for any claim, damages, or other liability arising 
.* from its use or inability of use.This permission does not apply to any documentation 
.* associated with this file for which ETSI keeps all rights reserved. The present 
.* copyright notice shall be included in all copies of whole or part of this 
.* file and shall not imply any sub-license right.
.*
.*  Modified by: Elemer Lelik
.*
.******************************************************************************/
text.
:lang eng.
.*
:docname.Test Description
:docno.
:rev.
:date.2020-11-11
.*
:prep. Elemer Lelik
:subresp.
:appr.
:checked.
.*
:title.ETSI TTCN3 Negative Conformance Test
:contents level=3.
.*---------------------------------------------------------------------*
:h1.PREREQUISITES AND PREPARATIONS
.*---------------------------------------------------------------------*	
.*---------------------------------------------------------------------*
:h2.Scope of the Test Object
.*---------------------------------------------------------------------*
:xmp tab=1 nokeep.
This TD contains negative OOP test  modules from ETSI TTCN3 Conformance Test's 50101_modules folders. 

:exmp.

.*---------------------------------------------------------------------*
:h2.Test Tools
.*---------------------------------------------------------------------*
:p.:us.Software Tools:eus.
:xmp tab=2 nokeep.

	SAtester_OOP.pl

:exmp.
:np.

.*---------------------------------------------------------------------*
:h1.REQUIREMENT-BASED TESTS
.*---------------------------------------------------------------------*
.*---------------------------------------------------------------------*
:h2. 5010101_scope_rules folder
.*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
:h3. NegSem_5010101_scopeRules_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010101_scopeRules_001 >

<COMPILE>

<MODULE TTCN NegSem_5010101_scopeRules_001 NegSem_5010101_scopeRules_001.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.1, Ensure that reusing identifiers of members of the component type specified in the runs on clause of the class for members and inside methods for formal parameters and local declarations is not allowed
 ** @verdict pass reject
*****************************************************************/

//https://bugs.eclipse.org/bugs/show_bug.cgi?id=568714
module NegSem_5010101_scopeRules_001 "TTCN-3:2018 Object-Oriented" {
    
    type component GeneralComp {
        const integer c_i := 5;
    }

 public type class MyClass runs on GeneralComp {
        public const integer c_i := 8; //not allowed

        function DoNothing(integer c_i := 11) { //not allowed
            log("Not allowed this type of reusing IDs.");
        }
    }

    testcase TC_NegSem_5010101_scopeRules_001() runs on GeneralComp {
        //var MyClass v_a := MyClass.create();  FIXME!!!
        var MyClass v_a := MyClass.create(8);
        if (v_a.c_i != c_i) {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_5010101_scopeRules_001());
    }
}
<END_MODULE>

<RESULT COUNT>
error
<END_RESULT>

<END_TC>
:exmp

.*---------------------------------------------------------------------*
:h2. 5010102_abstract_classes folder
.*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
:h3. NegSem_5010102_abstractClasses_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010102_abstractClasses_001 >

<COMPILE>

<MODULE TTCN NegSem_5010102_abstractClasses_001 NegSem_5010102_abstractClasses_001.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.2, Ensure that abstract classes cannot be explicitly instantiated.  
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010102_abstractClasses_001 "TTCN-3:2018 Object-Oriented" {
    
    type component GeneralComp {
    }

    public type class @abstract t_class_abstract {
       // public function log_sending(); //FIXME!!
        public function log_sending() {}; 
    }

    public type class t_class_subclass extends t_class_abstract {  // ???? not needed

        public function log_sending() {
            log("Sending messages!!!");
        }
    }

    testcase TC_NegSem_5010102_abstractClasses_001() runs on GeneralComp {
        var t_class_abstract v_a := t_class_abstract.create(); //not allowed
        setverdict(pass);
    }

    control {
        execute(TC_NegSem_5010102_abstractClasses_001());
    }
}
<END_MODULE>

<RESULT COUNT>
error: Cannot create an instance of abstract class type
<END_RESULT>

<END_TC>
:exmp

.*---------------------------------------------------------------------*
:h2. 5010103_external_classes folder
.*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
:h3. NegSem_5010103_externalClasses_001a negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010103_externalClasses_001a >

<COMPILE>

<MODULE TTCN NegSem_5010103_externalClasses_001a NegSem_5010103_externalClasses_001a.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.3, Ensure that external classes shall not contain fields or functions with a body.
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010103_externalClasses_001a "TTCN-3:2018 Object-Oriented" {
    
    type component GeneralComp {
    }

    type external class Java_Int_List {
        function add(integer v) {  //not allowed
            log("Add v to integer list"); 
        }
        function get(integer index) return integer;
       // const charstring c_a := "ret"; //not allowed
    }

    testcase TC_NegSem_5010103_externalClasses_001a() runs on GeneralComp {
        //empty testcase
        setverdict(pass);
    }

    control {
        execute(TC_NegSem_5010103_externalClasses_001a());
    }
}
<END_MODULE>

<RESULT COUNT>
error: An external class cannot contain a function
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_5010103_externalClasses_001b negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010103_externalClasses_001b >

<COMPILE>

<MODULE TTCN NegSem_5010103_externalClasses_001b NegSem_5010103_externalClasses_001b.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.3, Ensure that external classes shall not contain fields or functions with a body.
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010103_externalClasses_001b "TTCN-3:2018 Object-Oriented" {
    
    type component GeneralComp {
    }

    type external class Java_Int_List {
       // function add(integer v) {  //not allowed
       //     log("Add v to integer list"); 
       // }
        function get(integer index) return integer;
       const charstring c_a := "ret"; //not allowed
    }

    testcase TC_NegSem_5010103_externalClasses_001b() runs on GeneralComp {
        //empty testcase
        setverdict(pass);
    }

    control {
        execute(TC_NegSem_5010103_externalClasses_001b());
    }
}
<END_MODULE>

<RESULT COUNT>
error: An external class cannot contain a constant
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_5010103_externalClasses_002 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010103_externalClasses_002 >

<COMPILE>

<MODULE TTCN NegSem_5010103_externalClasses_002 NegSem_5010103_externalClasses_002.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.3, Ensure that external classes shall not be derived from non-external classes.
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010103_externalClasses_002 "TTCN-3:2018 Object-Oriented" {
    
    type component GeneralComp {
    }

    type class @abstract Collection_Interface {
        //function add(integer v) ; //FIXME!!!
        function add(integer v) {};
    }

    type external class Java_Int_List extends Collection_Interface { //not allowed
        function add(integer v);
        function get(integer index) return integer;
    }

    testcase TC_NegSem_5010103_externalClasses_002() runs on GeneralComp {
        //empty testcase
        setverdict(pass);
    }

    control {
        execute(TC_NegSem_5010103_externalClasses_002());
    }
}
<END_MODULE>

<RESULT COUNT>
error: An external class cannot extend an internal class
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_5010104_finalClasses_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010104_finalClasses_001 >

<COMPILE>

<MODULE TTCN NegSem_5010104_finalClasses_001 NegSem_5010104_finalClasses_001.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.4, Ensure that final classes cannot be abstract.
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010104_finalClasses_001 "TTCN-3:2018 Object-Oriented" {
    
    type component GeneralComp {
    }

    type class @final @abstract FinalClass { //not allowed
        function doSomething() return charstring  { //not allowed
            return "something";
        }
    }

    testcase TC_NegSem_5010104_finalClasses_001() runs on GeneralComp {
        var FinalClass v_a := FinalClass.create();
        if (v_a.doSomething() == "something") {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_5010104_finalClasses_001());
    }
}

<END_MODULE>

<RESULT COUNT>
error: Final classes cannot be abstract
<END_RESULT>

<END_TC>
:exmp

.*---------------------------------------------------------------------*
:h2. 5010107_methods folder
.*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
:h3. NegSem_5010107_Methods_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010107_Methods_001 >

<COMPILE>

<MODULE TTCN NegSem_5010107_Methods_001 NegSem_5010107_Methods_001.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.7, Ensure that public methods shall be overridden only by public methods.
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010107_Methods_001 "TTCN-3:2018 Object-Oriented" {

    type component GeneralComp {
    }
    
    type class MySuperClass {
        var octetstring v_o;

        public function doSomething() return integer {
            return oct2int(this.v_o);
        }
    }

    type class MySubClass extends MySuperClass {

        private function doSomething() return integer { //not allowed  FIXME !!!error should be thrown here !!!
            return 1; 
        }
    }

 /*   testcase TC_NegSem_5010107_Methods_001() runs on GeneralComp {
        var MySubClass v_a := MySubClass.create('AAFF'O) //: MySuperClass(); FIXME !!!
        if (v_a.doSomething() == 1) {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_5010107_Methods_001());
    }
 */   
}
<END_MODULE>

<RESULT COUNT>
426
error: Public methods can be only overridden by public methods
Elemer Lelik's avatar
Elemer Lelik committed
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_5010107_Methods_002 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010107_Methods_002 >

<COMPILE>

<MODULE TTCN NegSem_5010107_Methods_002 NegSem_5010107_Methods_002.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.7, Ensure that protected methods may be overridden by public or protected methods only.
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010107_Methods_002 "TTCN-3:2018 Object-Oriented" {

    type component GeneralComp {
    }
    
    type class MySuperClass {
        var octetstring v_o;

         function doSomething() return integer { //protected method
            return oct2int(this.v_o);
        }
    }

    type class MySubClass extends MySuperClass {

        private function doSomething() return integer { //not allowed  error should be thrown here FIXME!!!
            return 1;
        }
    }

  /*  testcase TC_NegSem_5010107_Methods_002() runs on GeneralComp {
        var MySubClass v_a := MySubClass.create('AAFF'O) // : MySuperClass(); FIXME!!!
        if (v_a.doSomething() == 1) {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_5010107_Methods_002());
    }
    */
}
<END_MODULE>

<RESULT COUNT>
485
error: Protected methods can be only overridden by public or protected methods
Elemer Lelik's avatar
Elemer Lelik committed
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_5010107_Methods_003a negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010107_Methods_003a >

<COMPILE>

<MODULE TTCN NegSem_5010107_Methods_003a NegSem_5010107_Methods_003a.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.7, Ensure that The return type of an overriding function shall be the same as the return type of the overridden function with the same template restrictions and modifiers.
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010107_Methods_003 "TTCN-3:2018 Object-Oriented" {

    type component GeneralComp {
    }

    type integer Mytype1;
    type charstring Mytype2;
    
    type class MySuperClass {
        var octetstring v_o;

         function doSomething() return Mytype1 {
            return oct2int(this.v_o);
        }
    }

    type class MySubClass extends MySuperClass {

        // /*protected*/ function doSomething() return Mytype2 { // not allowed
        public  function doSomething() return Mytype2 { //not allowed
            return "1";
        }
    }

    testcase TC_NegSem_5010107_Methods_003() runs on GeneralComp {
        var MySubClass v_a := MySubClass.create('AAFF'O) //: MySuperClass(); FIXME!!!
        if (v_a.doSomething() == "1") {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_5010107_Methods_003());
    }
}
<END_MODULE>

<RESULT COUNT>
error: The prototype of method `doSomething' is not identical to that of inherited method
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_5010107_Methods_004 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010107_Methods_004 >

<COMPILE>

<MODULE TTCN NegSem_5010107_Methods_004 NegSem_5010107_Methods_004.ttcn >
 /*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
  ** @purpose 5.1.1.7, Ensure that is  'runs on, mtc, system' clauses are not permitted  on  methods.
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010107_Methods_004 "TTCN-3:2018 Object-Oriented" {

    type component GeneralComp {
    }
    
    type class MySuperClass runs on GeneralComp {
        var octetstring v_o;

         function doSomething() return integer runs on GeneralComp { //not allowed
            return oct2int(this.v_o);
        }
    }

    type class MySubClass extends MySuperClass {

        function doSomething() return integer runs on GeneralComp {
            return 1;
        }
    }

    testcase TC_NegSem_5010107_Methods_004() runs on GeneralComp {
        var MySubClass v_a := MySubClass.create('AAFF'O) //: MySuperClass(); FIXME!!!
        if (v_a.doSomething() == 1) {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_5010107_Methods_004());
    }
}
<END_MODULE>

<RESULT COUNT>
error: at or before token `runs': syntax error, unexpected RunsKeyword
<END_RESULT>

<END_TC>
:exmp

.*---------------------------------------------------------------------*
:h2. 5010109_visibility folder
.*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
:h3. NegSem_5010109_Visibility_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010109_Visibility_001 >

<COMPILE>

<MODULE TTCN NegSem_5010109_Visibility_001 NegSem_5010109_Visibility_001.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.9, Ensure that fields can be declared as private or protected only.
 ** @verdict pass reject
*****************************************************************/
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=568755
module NegSem_5010109_Visibility_001 "TTCN-3:2018 Object-Oriented" {
    
    type component GeneralComp {
    }

    type class MyClass {
        public var integer v_i; // not allowed   should not compile!!!  FIXME!!!
    }

 /*   testcase TC_NegSem_5010109_Visibility_001() runs on GeneralComp {
        var MyClass v_a := MyClass.create(1);
        if (v_a.v_i == 1) {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_5010109_Visibility_001());
    }
  */  
}
<END_MODULE>

<RESULT COUNT>
error: Class members cannot be public
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_5010109_Visibility_002 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010109_Visibility_002 >

<COMPILE>

<MODULE TTCN NegSem_5010109_Visibility_002 NegSem_5010109_Visibility_002.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
  ** @purpose 5.1.1.9, Ensure that a field of any visibility cannot be overridden in a subclass.  
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010109_Visibility_002 "TTCN-3:2018 Object-Oriented" {
    
    type component GeneralComp {
    }

    type charstring MyType;

    type class MySuperClass {
        private var MyType v_my;
    }

    type class MySubClass extends MySuperClass {
        var MyType v_my; //not allowed
    }

    testcase TC_NegSem_5010109_Visibility_002() runs on GeneralComp {
        var MySubClass v_a := MySubClass.create("abc");
        if (v_a.v_my == "abc") {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_5010109_Visibility_002());
    }
}
<END_MODULE>

<RESULT COUNT>
error: variable `@NegSem_5010109_Visibility_002.MySubClass.v_my' shadows inherited member
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_5010109_Visibility_003 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010109_Visibility_003 >

<COMPILE>

<MODULE TTCN NegSem_5010109_Visibility_003 NegSem_5010109_Visibility_003.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.9, Ensure that a public member function can only be overridden by another public member function. 
 ** @verdict pass reject
*****************************************************************/

module NegSem_5010109_Visibility_003 "TTCN-3:2018 Object-Oriented" {

    type component GeneralComp {
    }

    type class MySuperClass {
        var integer v_i;

        public function f_add(integer inint) return integer {
            return this.v_i + inint;
        }
    }

    type class MySubClass extends MySuperClass {

            function f_add(integer inint) return integer { //not allowed  should throw an error here FIXME!!!
             return this.v_i + 1;
        }
    }

 /*   testcase TC_NegSem_5010109_Visibility_003() runs on GeneralComp {
        var MySubClass v_a := MySubClass.create(1);
        if (v_a.f_add(2) == 3) {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_5010109_Visibility_003());
    }
  */  
}
<END_MODULE>

<RESULT COUNT>
771
error: Public methods can be only overridden by public methods
Elemer Lelik's avatar
Elemer Lelik committed
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_5010109_Visibility_004 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_5010109_Visibility_004 >

<COMPILE>

<MODULE TTCN NegSem_5010109_Visibility_004 NegSem_5010109_Visibility_004.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.9, Ensure that private members can only be accessed directly from inside their surrounding class's scope.  
 ** @verdict pass reject
*****************************************************************/
module NegSem_5010109_Visibility_004 "TTCN-3:2018 Object-Oriented" {

    type component GeneralComp {
    }

    type class MyClass {
        private var integer v_i;
    }

    testcase TC_NegSem_5010109_Visibility_004() runs on GeneralComp {
        var MyClass v_a := MyClass.create(1);
        if (v_a.v_i == 1) { //not allowed
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_5010109_Visibility_004());
    }
}
<END_MODULE>

<RESULT COUNT>
error: The member definition `v_i' in class type `MyClass' is not visible in this scope
<END_RESULT>

<END_TC>
:exmp


.*---------------------------------------------------------------------*
:h2. 50101_top_level folder
.*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_50101_top_level_001 >

<COMPILE>

<MODULE TTCN NegSem_50101_top_level_001 NegSem_50101_top_level_001.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.0, Ensure that a class members' names are unique.
 ** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_001 "TTCN-3:2018 Object-Oriented" {

    type component GeneralComp {
    }

    public type class t_class_member_overloading {
        
        var integer v_i := 10;
        var integer v_i := 5; // not allowed
    }

    testcase TC_NegSem_50101_top_level_001() runs on GeneralComp {
        //var t_class_member_overloading v_a := t_class_member_overloading.create(); FIXME!!!
        var t_class_member_overloading v_a := t_class_member_overloading.create(10);
        if (v_a.v_i == 5) {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_50101_top_level_001());
    }
}
<END_MODULE>

<RESULT COUNT>
error: Duplicate definition with name `v_i'
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_002 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_50101_top_level_002 >

<COMPILE>

<MODULE TTCN NegSem_50101_top_level_002 NegSem_50101_top_level_002.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.0, Ensure that a class members' names are unique.
 ** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_002 "TTCN-3:2018 Object-Oriented" {

    type component GeneralComp {
    }

    public type class t_class_member_overloading {
        
        var integer v_i := 10;
        public function v_i() return integer { // not allowed
            return 5;
        }
    }

    testcase TC_NegSem_50101_top_level_002() runs on GeneralComp {
        //var t_class_member_overloading v_a := t_class_member_overloading.create();  FIXME!!!
        var t_class_member_overloading v_a := t_class_member_overloading.create(10);
        if (v_a.v_i() == 5) {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_50101_top_level_002());
    }
}
<END_MODULE>

<RESULT COUNT>
error: Duplicate definition with name `v_i'
<END_RESULT>

<END_TC>
:exmp


*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_003 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_50101_top_level_003 >

<COMPILE>

<MODULE TTCN NegSem_50101_top_level_003 NegSem_50101_top_level_003.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.0, Ensure that templates are not allowed for class types.
 ** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_003 "TTCN-3:2018 Object-Oriented" {

     type component GeneralComp {
     }

    public type template class t_templ_class_const_field { //not allowed
        private const charstring cons_ver_id := "0.0.1";

        public function get_cons_verid() return charstring {
            return this.cons_ver_id;
        }
    }

    testcase TC_NegSem_50101_top_level_003() runs on GeneralComp {
        //var t_templ_class_const_field v_a := t_templ_class_const_field.create();  FIXME!!!
        var t_templ_class_const_field v_a := t_templ_class_const_field.create("0.0.1");
        if (v_a.get_cons_verid() == "0.0.1") {
            setverdict(pass);
        } else {
            setverdict(fail);
        }
    }

    control {
        execute(TC_NegSem_50101_top_level_003());
    }   
    
}
<END_MODULE>

<RESULT COUNT>
error: at or before token `template': syntax error, unexpected TemplateKeyword, expecting ClassKeyword
<END_RESULT>

<END_TC>
:exmp

*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_004 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - NegSem_50101_top_level_004 >

<COMPILE>

<MODULE TTCN NegSem_50101_top_level_004 NegSem_50101_top_level_004.ttcn >
/*****************************************************************
 ** @author  STF 572
 ** @version 0.0.1
 ** @purpose 5.1.1.0, Ensure that passing of object references to the create operation of a component type or a function started on another component is not allowed.
 ** @verdict pass reject
*****************************************************************/
For faster browsing, not all history is shown. View entire blame