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