Sync with 5.4.0
[deliverable/titan.core.git] / regression_test / namedActualParameters / namedparam.ttcn
1 /******************************************************************************
2 * Copyright (c) 2000-2015 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
8 module namedparam
9 {
10 type component C1
11 {}
12
13 type record twints // two ints
14 {
15 integer i1,
16 integer i2
17 }
18
19 type record R1
20 {
21 integer i1,
22 integer i2,
23 integer i3,
24 integer i4
25 }
26
27 function f1( integer param1, boolean param2 := true )
28 {
29 // log( param1, param2 );
30 }
31
32 function f2( in template twints par )
33 {
34 }
35
36 testcase tc1() runs on C1
37 {
38 // f1(); // syntax error, param1 missing
39 f1( 1 ); // correct, param2=true
40 f1( 1, - );
41 //~ f1( 1, true ); // same as above
42 // f1( 0, true, - ); // too many parameters
43 f1( 1, param2 := false );
44
45 /*
46 This is _valid_ syntax but bad semantics
47 (unary minus cannot be applied to a record value)
48 f2( - { 1,1 } );
49 */
50 //f1( { param1 := 1 } );
51
52 setverdict( pass ); // whew !
53 f2( /*par =*/ {13,14} );
54 }
55
56 testcase tc2() runs on C1
57 {
58 var R1 r0 := {
59 42,-,-,- // incomplete, other elements are unbound
60 }
61 var R1 r1 := { // value-list notation
62 1,
63 2,
64 3,
65 4
66 }
67 var R1 r2 := { // assignment notation
68 i1 := 1,
69 i2 := 2,
70 i3 := 3,
71 i4 := 4
72 }
73 var template R1 tr1 := { // value-list notation
74 1,
75 2,
76 3,
77 4
78 }
79 var template R1 tr2 := { // assignment notation
80 i1 := 1,
81 i2 := 2,
82 i3 := 3,
83 i4 := 4
84 }
85 /*
86 error: Field `i1' cannot appear after field `i3'
87 var template R1 tr3 := { // assignment notation
88 i3 := 3,
89 i1 := 1,
90 i2 := 2,
91 i4 := 4
92 }
93 */
94
95 /*
96 Value-list notation and assignment notation cannot be mixed:
97
98 var R1 r_bad := {
99 //1,
100 i2 := 2,
101 3
102 }
103 */
104
105 setverdict(pass);
106 }
107
108 testcase tc3(integer i, float up) runs on C1
109 {
110 setverdict ( pass );
111
112 }
113
114 control {
115 execute(tc1());
116 execute(tc2());
117
118 execute(tc3(1, 2.3)); // unnamed only
119 execute(tc3(i:=2, up:=0.0)); // named only
120 execute(tc3(3, up:=6.66)); // mix (regression test for TR925)
121 }
122 }
This page took 0.05159 seconds and 5 git commands to generate.