File: TtemplateBool.ttcn

package info (click to toggle)
eclipse-titan 8.2.0-1
  • links: PTS
  • area: main
  • in suites: bookworm, sid
  • size: 103,544 kB
  • sloc: cpp: 271,008; ansic: 33,683; yacc: 23,419; makefile: 15,483; lex: 9,204; java: 4,848; perl: 4,555; sh: 2,242; xml: 1,378; javascript: 85; awk: 48; php: 32; python: 13
file content (219 lines) | stat: -rw-r--r-- 6,945 bytes parent folder | download
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
/******************************************************************************
 * Copyright (c) 2000-2021 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Raduly, Csaba
 *   Szabados, Kristof
 *   Szabo, Janos Zoltan – initial implementation
 *
 ******************************************************************************/
module TtemplateBool {
type component templateBool_mycomp {};
type record templateBool_rec {
 boolean x1,
 boolean x2,
 boolean x3 optional };
template templateBool_rec templateBool_tSpec :={ //specific values
 x1:=true,
 x2:=false,
 x3:=false };
template templateBool_rec templateBool_tList :={ //specific value and value list
 x1:=true,
 x2:=(false),
 x3:=false };
template templateBool_rec templateBool_tComp :={ //specific value and compl. list
 x1:=true,
 x2:=complement (true),
 x3:=false };
template templateBool_rec templateBool_tOmit :={ //omitting values
 x1:=true,
 x2:=false,
 x3:=omit } ;
template templateBool_rec templateBool_tAny :={ //specific and any value
 x1:=true,
 x2:=false,
 x3:=? } ;
template templateBool_rec templateBool_tAnyorNone :={ //specific and AnyorNone value
 x1:=true,
 x2:=false,
 x3:=* };
template templateBool_rec templateBool_tIfpresent :={ //specific value and ifpresent
 x1:=true,
 x2:=false,
 x3:=false ifpresent };

testcase templateBoolSpec() runs on templateBool_mycomp {
var templateBool_rec x1,x2;		//specific value
x1:={ x1:=true,  x2:=false,  x3:=false };
x2:={ x1:=true,  x2:=true,  x3:=false };
//match
if (match(x1,templateBool_tSpec)) {setverdict(pass);}
 else {setverdict(fail);}
//no match
if (not(match(x2,templateBool_tSpec))) {setverdict(pass);}
 else {setverdict(fail);}
}

testcase templateBoolList() runs on templateBool_mycomp {
var templateBool_rec x1,x2,x3;		//value list
x1:={ x1:=true,  x2:=false,  x3:=false };
x2:={ x1:=true,  x2:=true,  x3:=false };
x3:={ x1:=false,  x2:=false,  x3:=false };
//match
if (match(x1,templateBool_tList)) {setverdict(pass);}
 else {setverdict(fail);}
//no match: out of list
if (not(match(x2,templateBool_tList))) {setverdict(pass);}
 else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateBool_tList))) {setverdict(pass);}
 else {setverdict(fail);}
}

testcase templateBoolComp() runs on templateBool_mycomp {
var templateBool_rec x1,x2,x3;		//complemented list
x1:={ x1:=true,  x2:=false,  x3:=false };
x2:={ x1:=true,  x2:=true,  x3:=false };
x3:={ x1:=false,  x2:=false,  x3:=false };
//match
if (match(x1,templateBool_tComp)) {setverdict(pass);}
 else {setverdict(fail);}
//no match: in the list
if (not(match(x2,templateBool_tComp))) {setverdict(pass);}
 else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateBool_tComp))) {setverdict(pass);}
 else {setverdict(fail);}
}

testcase templateBoolOmit() runs on templateBool_mycomp {
var templateBool_rec x1,x2,x3;		//omitting value
x1:={ x1:=true,  x2:=false,  x3:=omit };
x2:={ x1:=true,  x2:=false,  x3:=true };
x3:={ x1:=false,  x2:=false,  x3:=omit };
//match
if (match(x1,templateBool_tOmit)) {setverdict(pass);}
 else {setverdict(fail);}
//no match: not omitted
if (not(match(x2,templateBool_tOmit))) {setverdict(pass);}
 else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateBool_tOmit))) {setverdict(pass);}
 else {setverdict(fail);}
}

testcase templateBoolAny() runs on templateBool_mycomp {
var templateBool_rec x1,x2,x3;		//any value
x1:={ x1:=true,  x2:=false,  x3:=false };
x2:={ x1:=true,  x2:=false,  x3:=omit };
x3:={ x1:=false,  x2:=false,  x3:=false };
//match
if (match(x1,templateBool_tAny)) {setverdict(pass);}
 else {setverdict(fail);}
//no match: field omitted
if (not(match(x2,templateBool_tAny))) {setverdict(pass);}
 else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateBool_tAny))) {setverdict(pass);}
 else {setverdict(fail);}
}

testcase templateBoolAnyorNone() runs on templateBool_mycomp {
var templateBool_rec x1,x2,x3;		//AnyorNone value
x1:={ x1:=true,  x2:=false,  x3:=omit };
x2:={ x1:=true,  x2:=false,  x3:=true };
x3:={ x1:=false,  x2:=false,  x3:=omit };
//match: omitted
if (match(x1,templateBool_tAnyorNone)) {setverdict(pass);}
 else {setverdict(fail);}
//match: value
if (match(x2,templateBool_tAnyorNone)) {setverdict(pass);}
 else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateBool_tAnyorNone))) {setverdict(pass);}
 else {setverdict(fail);}
}

testcase templateBoolIfpresent() runs on templateBool_mycomp {
var templateBool_rec x1,x2,x3,x4;		//ifpresent
x1:={ x1:=true,  x2:=false,  x3:=false };
x2:={ x1:=true,  x2:=false,  x3:=omit };
x3:={ x1:=true,  x2:=false,  x3:=true };
x4:={ x1:=false,  x2:=false,  x3:=omit };
//match: present and match
if (match(x1,templateBool_tIfpresent)) {setverdict(pass);}
 else {setverdict(fail);}
//match: not present
if (match(x2,templateBool_tIfpresent)) {setverdict(pass);}
 else {setverdict(fail);}
//no match: present and not match
if (not(match(x3,templateBool_tIfpresent))) {setverdict(pass);}
 else {setverdict(fail);}
//no match: other field
if (not(match(x4,templateBool_tIfpresent))) {setverdict(pass);}
 else {setverdict(fail);}
}

function f_opposite(boolean p_par) return boolean {
  return not p_par;
}

template boolean t_conjunction := conjunct(false, @dynamic f_opposite);

template boolean t_implication := true implies @dynamic f_opposite;

template boolean t_dynamic(boolean p_par) := @dynamic {
  return value and p_par;
}

testcase templateBoolConjunction() runs on templateBool_mycomp {
  var boolean v1 := true, v2 := false;
  if (match(v1, t_conjunction)) {
    setverdict(fail, match(v1, t_conjunction));
  }
  if (not match(v2, t_conjunction)) {
    setverdict(fail, match(v2, t_conjunction));
  }
  setverdict(pass);
}

testcase templateBoolImplication() runs on templateBool_mycomp {
  var boolean v1 := true, v2 := false;
  if (match(v1, t_implication)) {
    setverdict(fail, match(v1, t_implication));
  }
  if (not match(v2, t_implication)) {
    setverdict(fail, match(v2, t_implication));
  }
  setverdict(pass);
}

testcase templateBoolDynamic() runs on templateBool_mycomp {
  var boolean v1 := true, v2 := false;
  if (not match(v1, t_dynamic(true))) {
    setverdict(fail, match(v1, t_dynamic(true)));
  }
  if (match(v2, t_dynamic(true))) {
    setverdict(fail, match(v2, t_dynamic(true)));
  }
  setverdict(pass);
}

control {
 execute(templateBoolSpec());
 execute(templateBoolList());
 execute(templateBoolComp());
 execute(templateBoolOmit());
 execute(templateBoolAny());
 execute(templateBoolAnyorNone());
 execute(templateBoolIfpresent());
 execute(templateBoolConjunction());
 execute(templateBoolImplication());
 execute(templateBoolDynamic());
}
}