Commit | Line | Data |
---|---|---|
970ed795 | 1 | /****************************************************************************** |
3abe9331 | 2 | * Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
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 io { | |
9 | type component O {} | |
10 | ||
11 | ||
12 | //The following TTCN code is not accepted (from HN81328) | |
13 | ||
14 | type record MyRecord1 { | |
15 | integer a, | |
16 | boolean b optional | |
17 | // , float f | |
18 | } | |
19 | ||
20 | type set MySet1 { | |
21 | integer a, | |
22 | boolean b optional | |
23 | // , float f | |
24 | } | |
25 | ||
26 | type record MyRecord2 { | |
27 | MyRecord1 m | |
28 | } | |
29 | ||
30 | type set MySet2 { | |
31 | MySet1 m | |
32 | } | |
33 | ||
34 | template MyRecord1 MyTemplate1ln := { ? } | |
35 | with {optional "implicit omit"} // b is set to omit, ERROR BY TITAN | |
36 | ||
37 | //The compiler complains that there are too few elements in the list (one instead of two). | |
38 | // Common::Location::error is called from from Ttcn::Template::set_templatetype | |
39 | // in case TEMPLATE_LIST | |
40 | ||
41 | //The following (using assignment notation) is accepted: | |
42 | ||
43 | template MyRecord1 MyTemplate1an := { a := ? } | |
44 | with {optional "implicit omit"} // b is set to omit | |
45 | ||
46 | template MySet1 MySetTemplate1an := { a := ? } | |
47 | with {optional "implicit omit"} // b is set to omit | |
48 | ||
49 | function check1(in template MyRecord1 r1, in boolean a_init1, in boolean b_init1, | |
50 | out charstring reason1) return boolean | |
51 | { | |
52 | var charstring t_str := log2str(r1); | |
53 | // looks like: { a := ?, b := <uninitialized template> } | |
54 | if (not a_init1 and not b_init1) | |
55 | { | |
56 | return t_str == "<uninitialized template>"; | |
57 | } | |
58 | else | |
59 | { | |
60 | var charstring rx := "{ a := (*), b := (*) }"; | |
61 | ||
62 | var charstring grp := regexp(t_str, rx, 0); | |
63 | log("grp for a :", grp); | |
64 | if (grp != "?") { // a is always expected to be '?' | |
65 | reason1 := " a should be "; | |
66 | if (a_init1) { reason1 := reason1 & "initialised" } | |
67 | else { reason1 := reason1 & "uninitialised" } // never gets here | |
68 | return false; | |
69 | } | |
70 | ||
71 | grp := regexp(t_str, rx, 1); | |
72 | log("grp for b :", grp); | |
73 | reason1 := " b should be " | |
74 | ||
75 | if (b_init1) { | |
76 | if (grp != "omit") { | |
77 | reason1 := reason1 & "initialised" | |
78 | return false; | |
79 | } | |
80 | } | |
81 | else { | |
82 | if (grp != "<uninitialized template>") { | |
83 | reason1 := reason1 & "uninitialised" | |
84 | return false; | |
85 | } | |
86 | } | |
87 | return true; | |
88 | } | |
89 | } | |
90 | ||
91 | function check1s(in template MySet1 r5, in boolean a_init5, in boolean b_init5, | |
92 | out charstring reason5) return boolean | |
93 | { | |
94 | var charstring t_str := log2str(r5); | |
95 | // looks like: { a := ?, b := <uninitialized template> } | |
96 | if (not a_init5 and not b_init5) | |
97 | { | |
98 | return t_str == "<uninitialized template>"; | |
99 | } | |
100 | else | |
101 | { | |
102 | var charstring rx := "{ a := (*), b := (*) }"; | |
103 | ||
104 | var charstring grp := regexp(t_str, rx, 0); | |
105 | log("grp for a :", grp); | |
106 | if (grp != "?") { // a is always expected to be '?' | |
107 | reason5 := " a should be "; | |
108 | if (a_init5) { reason5 := reason5 & "initialised" } | |
109 | else { reason5 := reason5 & "uninitialised" } // never gets here | |
110 | return false; | |
111 | } | |
112 | ||
113 | grp := regexp(t_str, rx, 1); | |
114 | log("grp for b :", grp); | |
115 | reason5 := " b should be " | |
116 | ||
117 | if (b_init5) { | |
118 | if (grp != "omit") { | |
119 | reason5 := reason5 & "initialised" | |
120 | return false; | |
121 | } | |
122 | } | |
123 | else { | |
124 | if (grp != "<uninitialized template>") { | |
125 | reason5 := reason5 & "uninitialised" | |
126 | return false; | |
127 | } | |
128 | } | |
129 | return true; | |
130 | } | |
131 | } | |
132 | ||
133 | function check2(in template MyRecord2 r2, in boolean a_init2, in boolean b_init2, | |
134 | out charstring reason2) return boolean | |
135 | { | |
136 | if (a_init2 or b_init2) { | |
137 | return check1(r2.m, a_init2, b_init2, reason2); | |
138 | } | |
139 | else { | |
140 | return log2str(r2) == "<uninitialized template>"; | |
141 | } | |
142 | } | |
143 | ||
144 | function check2s(in template MySet2 r2s, in boolean a_init2s, in boolean b_init2s, | |
145 | out charstring reason2s) return boolean | |
146 | { | |
147 | if (a_init2s or b_init2s) { | |
148 | return check1s(r2s.m, a_init2s, b_init2s, reason2s); | |
149 | } | |
150 | else { | |
151 | return log2str(r2s) == "<uninitialized template>"; | |
152 | } | |
153 | } | |
154 | ||
155 | /***************************** from 27.7 of the TTCN3 standard 4.1.1 *****************************/ | |
156 | ||
157 | // reference templates with explicitly set fields | |
158 | template MyRecord1 MyTemplate1 := { a := ?, b := omit } | |
159 | template MyRecord2 MyTemplate2 := { m := { a := ?, b := omit }} | |
160 | ||
161 | template MySet1 MySetTemplate1 := { a := ?, b := omit } | |
162 | template MySet2 MySetTemplate2 := { m := { a := ?, b := omit }} | |
163 | ||
164 | ||
165 | testcase tc12() runs on O | |
166 | { | |
167 | var charstring reason; | |
168 | if (check1(MyTemplate1, true, true, reason)) { setverdict(pass); } | |
169 | else { setverdict(fail, reason); } | |
170 | ||
171 | if (check1s(MySetTemplate1, true, true, reason)) { setverdict(pass); } | |
172 | else { setverdict(fail, reason); } | |
173 | ||
174 | if (check2(MyTemplate2, true, true, reason)) { setverdict(pass); } | |
175 | else { setverdict(fail, reason); } | |
176 | ||
177 | if (check2s(MySetTemplate2, true, true, reason)) { setverdict(pass); } | |
178 | else { setverdict(fail, reason); } | |
179 | } | |
180 | ||
181 | // reference templates | |
182 | template MyRecord1 MyTemplate1a := { a := ? } // b is undefined | |
183 | template MyRecord1 MyTemplate1b := { a := ? } with {optional "explicit omit"} // b is undefined | |
184 | ||
185 | template MySet1 MySetTemplate1a := { a := ? } // b is undefined | |
186 | template MySet1 MySetTemplate1b := { a := ? } with {optional "explicit omit"} // b is undefined | |
187 | ||
188 | testcase tc1ab() runs on O | |
189 | { | |
190 | var charstring reason; | |
191 | if (check1(MyTemplate1a, true, false, reason)) { setverdict(pass); } | |
192 | else { setverdict(fail, reason); } | |
193 | ||
194 | if (check1s(MySetTemplate1a, true, false, reason)) { setverdict(pass); } | |
195 | else { setverdict(fail, reason); } | |
196 | ||
197 | if (check1(MyTemplate1b, true, false, reason)) { setverdict(pass); } | |
198 | else { setverdict(fail, reason); } | |
199 | ||
200 | if (check1s(MySetTemplate1b, true, false, reason)) { setverdict(pass); } | |
201 | else { setverdict(fail, reason); } | |
202 | } | |
203 | ||
204 | template MyRecord2 MyTemplate2a := {} // m and its subfields are undefined, ERROR BY TITAN | |
205 | template MyRecord2 MyTemplate2b := { m := { a := ?}}; // m.b is undefined | |
206 | template MySet2 MySetTemplate2b := { m := { a := ?}}; // m.b is undefined | |
207 | ||
208 | testcase tc2ab() runs on O | |
209 | { | |
210 | var charstring reason; | |
211 | if (check2(MyTemplate2a, false, false, reason)) { setverdict(pass); } | |
212 | else { setverdict(fail, reason); } | |
213 | ||
214 | if (check2(MyTemplate2b, true, false, reason)) { setverdict(pass); } | |
215 | else { setverdict(fail, reason); } | |
216 | ||
217 | if (check2s(MySetTemplate2b, true, false, reason)) { setverdict(pass); } | |
218 | else { setverdict(fail, reason); } | |
219 | } | |
220 | ||
221 | // templates with attribute | |
222 | ||
223 | template MyRecord1 MyTemplate11 := { a := ? } with {optional "implicit omit"} | |
224 | // same as MyTemplate1, b is set to omit | |
225 | template MySet1 MySetTemplate11 := { a := ? } with {optional "implicit omit"} | |
226 | ||
227 | template MyRecord2 MyTemplate21 := { m := { a := ?}} with {optional "implicit omit"} | |
228 | // same as MyTemplate2, by recursive application of the attribute | |
229 | template MySet2 MySetTemplate21 := { m := { a := ?}} with {optional "implicit omit"} | |
230 | ||
231 | testcase tc_11() runs on O | |
232 | { | |
233 | var charstring reason; | |
234 | if (check1(MyTemplate11, true, true, reason)) { setverdict(pass); } | |
235 | else { setverdict(fail, reason, MyTemplate11); } | |
236 | ||
237 | if (check1s(MySetTemplate11, true, true, reason)) { setverdict(pass); } | |
238 | else { setverdict(fail, reason, MyTemplate11); } | |
239 | } | |
240 | ||
241 | testcase tc_21() runs on O | |
242 | { | |
243 | var charstring reason; | |
244 | if (check2(MyTemplate21, true, true, reason)) { setverdict(pass); } | |
245 | else { setverdict(fail, reason, MyTemplate21); } | |
246 | ||
247 | if (check2s(MySetTemplate21, true, true, reason)) { setverdict(pass); } | |
248 | else { setverdict(fail, reason, MyTemplate21); } | |
249 | } | |
250 | ||
251 | template MyRecord2 MyTemplate22 := { m := MyTemplate1a } with {optional "implicit omit"} | |
252 | // same as MyTemplate2, { m := { a := ?, b := omit }}, by recursive application of the attribute | |
253 | // MyTemplate1a has b undefined | |
254 | template MySet2 MySetTemplate22 := { m := MySetTemplate1a } with {optional "implicit omit"} | |
255 | ||
256 | testcase tc_22() runs on O | |
257 | { | |
258 | var charstring reason; | |
259 | if (check2(MyTemplate22, true, false, reason)) { setverdict(pass); } | |
260 | // According to the standard, this ^^^^^ should be true, but Titan does not implement recursive implicit omit | |
261 | else { setverdict(fail, MyTemplate22, reason); } | |
262 | ||
263 | if (check2s(MySetTemplate22, true, false, reason)) { setverdict(pass); } | |
264 | // According to the standard, this ^^^^^ should be true, but Titan does not implement recursive implicit omit | |
265 | else { setverdict(fail, MyTemplate22, reason); } | |
266 | } | |
267 | ||
268 | template MyRecord2 MyTemplate23 := {} with {optional "implicit omit"} // ERROR BY TITAN | |
269 | // same as MyTemplate2a, m remains undefined | |
270 | ||
271 | testcase tc_23() runs on O | |
272 | { | |
273 | var charstring reason; | |
274 | if (check2(MyTemplate23, false, false, reason)) { setverdict(pass); } | |
275 | else { setverdict(fail, MyTemplate23, reason); } | |
276 | } | |
277 | ||
278 | template MyRecord2 MyTemplate24 := { m := MyTemplate1b } with {optional "implicit omit"} | |
279 | // same as MyTemplate2b, the attribute on the lower scope is not overwritten | |
280 | template MySet2 MySetTemplate24 := { m := MySetTemplate1b } with {optional "implicit omit"} | |
281 | ||
282 | testcase tc_24() runs on O | |
283 | { | |
284 | var charstring reason; | |
285 | if (check2(MyTemplate22, true, false, reason)) { setverdict(pass); } | |
286 | else { setverdict(fail, MyTemplate24, reason); } | |
287 | ||
288 | if (check2s(MySetTemplate22, true, false, reason)) { setverdict(pass); } | |
289 | else { setverdict(fail, MyTemplate24, reason); } | |
290 | } | |
291 | ||
292 | template MyRecord2 MyTemplate25 := { m := MyTemplate1b } with {optional override "implicit omit"} | |
293 | // same as MyTemplate2, the attribute on the lower scope is overwritten | |
294 | // MyTemplate1b has b undefined and (redundant) explicit omit | |
295 | ||
296 | testcase tc_25() runs on O | |
297 | { | |
298 | var charstring reason; | |
299 | if (check2(MyTemplate25, true, false, reason)) { setverdict(pass); } | |
300 | // According to the standard, this ^^^^^ should be true, but Titan does not implement recursive implicit omit | |
301 | else { setverdict(fail, MyTemplate25, reason); } | |
302 | } | |
303 | ||
304 | /***************************** from 6.2 ***************************/ | |
305 | type record R62 { | |
306 | integer f1, | |
307 | integer f2 optional, | |
308 | integer f3, | |
309 | integer f4 optional, | |
310 | integer f5 optional | |
311 | } | |
312 | ||
313 | template R62 x1 := { 1, -, 2 } with {optional "implicit omit"} | |
314 | template R62 x2 := { 1, 2 } with {optional "implicit omit"} | |
315 | template R62 x3 := { 1, 2, 3 } with {optional "implicit omit"} | |
316 | // "const" gives the same old error: | |
317 | // Too few elements in value list notation for type `@io.R62' | |
318 | ||
319 | testcase tc62() runs on O | |
320 | { | |
321 | var charstring logged; | |
322 | logged := log2str(x1); | |
323 | if (match(logged, "{ f1 := 1, f2 := omit, f3 := 2, f4 := omit, f5 := omit }")) { setverdict(pass); } | |
324 | else { setverdict(fail, logged); } | |
325 | ||
326 | logged := log2str(x2); | |
327 | if (match(logged, "{ f1 := 1, f2 := 2, f3 := <uninitialized template>, f4 := omit, f5 := omit }")) { setverdict(pass); } | |
328 | else { setverdict(fail, logged); } | |
329 | ||
330 | logged := log2str(x3); | |
331 | if (match(logged, "{ f1 := 1, f2 := 2, f3 := 3, f4 := omit, f5 := omit }")) { setverdict(pass); } | |
332 | else { setverdict(fail, logged); } | |
333 | } | |
334 | ||
335 | //testcase passer() runs on O { setverdict(pass); } | |
336 | ||
337 | /////////////////////// | |
338 | // MODULE PARAMETERS // | |
339 | /////////////////////// | |
340 | type myrec1 myarr[2] | |
341 | type record myrec1 { integer i optional, charstring c } | |
342 | type set myset1 { integer i optional, charstring c } | |
343 | type record myrec2 { integer i optional, myrec1 mr1 optional, myrec1 mr2 } | |
344 | type set myset2 { integer i optional, myset1 ms1 optional, myset1 ms2 } | |
345 | type union myuni { integer i, myrec1 mr1, myrec2 mr2 } | |
346 | type record of myrec1 myrecof1 | |
347 | type set of myrec1 mysetof1 | |
348 | type record of myrec2 myrecof2 | |
349 | type set of myset2 mysetof2 | |
350 | modulepar myarr marr with { optional "implicit omit" } | |
351 | modulepar myrec1 mrec1 with { optional "implicit omit" } | |
352 | modulepar myset1 mset1 with { optional "implicit omit" } | |
353 | modulepar myrec2 mrec2 with { optional "implicit omit" } | |
354 | modulepar myset2 mset2 with { optional "implicit omit" } | |
355 | modulepar myuni muni with { optional "implicit omit" } | |
356 | modulepar myrecof1 mrecof1 with { optional "implicit omit" } | |
357 | modulepar mysetof1 msetof1 with { optional "implicit omit" } | |
358 | modulepar myrecof2 mrecof2 with { optional "implicit omit" } | |
359 | modulepar mysetof2 msetof2 /*:= { [0] := { ms2 := { c := "clinton" } } }*/ with { optional "implicit omit" } | |
360 | ||
361 | testcase tc_iompar_recset() runs on O | |
362 | { | |
363 | // For empty records: | |
364 | // B: { i := <unbound>, c := <unbound> } | |
365 | // A: { i := omit, c := <unbound> } | |
366 | var myrec1 brec1 := { c := "clementin" } | |
367 | var myrec1 arec1 := { i := omit, c := "clementin" } | |
368 | if (log2str(mrec1) == log2str(arec1)) { setverdict(pass) } else { setverdict(fail) } | |
369 | // Empty sets are not allowed. | |
370 | var myset1 bset1 := { c := "cup" } | |
371 | var myset1 aset1 := { i := omit, c := "cup" } | |
372 | if (log2str(mset1) == log2str(aset1)) { setverdict(pass) } else { setverdict(fail) } | |
373 | // B: { i := <unbound>, mr1 := <unbound>, mr2 := { i := <unbound>, c := "cello" } } | |
374 | // A: { i := omit, mr1 := omit, mr2 := { i := omit, c := "cello" } } | |
375 | var myrec2 brec2 := { mr2 := { c := "cello" } } | |
376 | var myrec2 arec2 := { omit, omit, { i := omit, c := "cello" } } | |
377 | if (log2str(mrec2) == log2str(arec2)) { setverdict(pass) } else { setverdict(fail) } | |
378 | // B: { i := <unbound>, ms1 := <unbound>, ms2 := { i := <unbound>, c := "cello" } } | |
379 | // A: { i := omit, ms1 := omit, ms2 := { i := omit, c := "cello" } } | |
380 | var myset2 bset2 := { ms2 := { c := "cello" } } | |
381 | var myset2 aset2 := { i := omit, ms1 := omit, ms2 := { i := omit, c := "cello" } } | |
382 | if (log2str(mset2) == log2str(aset2)) { setverdict(pass) } else { setverdict(fail) } | |
383 | } | |
384 | ||
385 | testcase tc_iompar_uni() runs on O | |
386 | { | |
387 | // B: { mr2 := { i := <unbound>, mr1 := <unbound>, mr2 := { i := <unbound>, c := "cuba" } } } | |
388 | // A: { mr2 := { i := omit, mr1 := omit, mr2 := { i := omit, c := "cuba" } } } | |
389 | var myuni buni := { mr2 := { mr2 := { c := "cuba" } } } | |
390 | var myuni auni := { mr2 := { i := omit, mr1 := omit, mr2 := { i := omit, c := "cuba" } } } | |
391 | if (log2str(muni) == log2str(auni)) { setverdict(pass) } else { setverdict(fail) } | |
392 | } | |
393 | ||
394 | testcase tc_iompar_listarr() runs on O | |
395 | { | |
396 | // B: { { i := <unbound>, c := <unbound> }, { i := <unbound>, c := "clementin" } } | |
397 | // A: { { i := <unbound>, c := <unbound> }, { i := omit, c := "clementin" } } | |
398 | var myarr barr := { [1] := { c := "clementin" } } | |
399 | var myarr aarr := { [1] := { i := omit, c := "clementin" } } | |
400 | if (log2str(marr) == log2str(aarr)) { setverdict(pass) } else { setverdict(fail) } | |
401 | // B: { { i := <unbound>, c := <unbound> }, { i := <unbound>, c := "clinton" } } | |
402 | // A: { { i := <unbound>, c := <unbound> }, { i := omit, c := "clinton" } } | |
403 | // Unbound values will not be checked at all. | |
404 | var myrecof1 brecof1 := { [1] := { c := "clinton" } } | |
405 | var myrecof1 arecof1 := { [1] := { i := omit, c := "clinton" } } | |
406 | if (log2str(mrecof1) == log2str(arecof1)) { setverdict(pass) } else { setverdict(fail) } | |
407 | // B: { { i := <unbound>, c := <unbound> }, { i := <unbound>, c := "clinton" } } | |
408 | // A: { { i := <unbound>, c := <unbound> }, { i := omit, c := "clinton" } } | |
409 | var mysetof1 bsetof1 := { [1] := { c := "clinton" } } | |
410 | var mysetof1 asetof1 := { [1] := { i := omit, c := "clinton" } } | |
411 | if (log2str(msetof1) == log2str(asetof1)) { setverdict(pass) } else { setverdict(fail) } | |
412 | // B: { { i := <unbound>, mr1 := <unbound>, mr2 := { i := <unbound>, c := <unbound> } }, { i := <unbound>, mr1 := <unbound>, mr2 := { i := <unbound>, c := "clinton" } } } | |
413 | // A: { { i := <unbound>, mr1 := <unbound>, mr2 := { i := <unbound>, c := <unbound> } }, { i := omit, mr1 := omit, mr2 := { i := omit, c := "clinton" } } } | |
414 | var myrecof2 brecof2 := { [1] := { mr2 := { c := "clinton" } } } | |
415 | var myrecof2 arecof2 := { [1] := { i := omit, mr1 := omit, mr2 := { i := omit, c := "clinton" } } } | |
416 | if (log2str(mrecof2) == log2str(arecof2)) { setverdict(pass) } else { setverdict(fail) } | |
417 | // B: { { i := <unbound>, ms1 := <unbound>, ms2 := { i := <unbound>, c := <unbound> } }, { i := <unbound>, ms1 := <unbound>, ms2 := { i := <unbound>, c := "clinton" } } } | |
418 | // A: { { i := <unbound>, ms1 := <unbound>, ms2 := { i := <unbound>, c := <unbound> } }, { i := omit, ms1 := omit, ms2 := { i := omit, c := "clinton" } } } | |
419 | var mysetof2 bsetof2 := { [1] := { ms2 := { c := "clinton" } } } | |
420 | var mysetof2 asetof2 := { [1] := { i := omit, ms1 := omit, ms2 := { i := omit, c := "clinton" } } } | |
421 | if (log2str(msetof2) == log2str(asetof2)) { setverdict(pass) } else { setverdict(fail) } | |
422 | } | |
423 | ||
424 | type record MyRecord { | |
425 | integer field1 optional, | |
426 | integer field2 optional, | |
427 | MySubRecord subRecord optional | |
428 | } | |
429 | type record MySubRecord { | |
430 | integer subField1 optional, | |
431 | integer subField2 optional | |
432 | } | |
433 | ||
434 | template MyRecord t_MyRecord1(integer v_int1, integer v_int2, MySubRecord v_subRecord) := { | |
435 | field1 := v_int1, | |
436 | field2 := v_int2, | |
437 | subRecord := v_subRecord | |
438 | } | |
439 | ||
440 | template MyRecord t_MyRecord2(integer v_int1, integer v_int2, MySubRecord v_subRecord) modifies t_MyRecord1 := { | |
441 | subRecord := v_subRecord | |
442 | } // without { optional "implicit omit" } | |
443 | ||
444 | template MyRecord t_MyRecord2_io(integer v_int1, integer v_int2, MySubRecord v_subRecord) modifies t_MyRecord1 := { | |
445 | subRecord := v_subRecord | |
446 | } with { optional "implicit omit" } | |
447 | ||
448 | template MyRecord t_MyRecord2_io2(integer v_int1, integer v_int2, MySubRecord v_subRecord) modifies t_MyRecord1 := { | |
449 | field1 := v_int1, | |
450 | field2 := v_int2, | |
451 | subRecord := v_subRecord | |
452 | } with { optional "implicit omit" } | |
453 | ||
454 | template MySubRecord t_MySubRecord(integer v_int1, integer v_int2) := { | |
455 | subField1 := v_int1, | |
456 | subField2 := v_int2 | |
457 | } with { optional "implicit omit" } | |
458 | ||
459 | // HP93133: "Implicit omit overwrites attributes of modified template" | |
460 | testcase tc_HP93133() runs on O { | |
461 | var MySubRecord subRecord := valueof(t_MySubRecord(1, 2)) // 1,2 | |
462 | var MyRecord record1 := valueof(t_MyRecord1(5, 6, subRecord)) // 5,6,1,2 | |
463 | // modifies without implicit omit: | |
464 | var MyRecord record2 := valueof(t_MyRecord2(7, 8, subRecord)) // 7,8,1,2 | |
465 | if (record2 == { 7, 8, { 1, 2 } }) { setverdict(pass) } else { setverdict(fail) } | |
466 | // modifies, with implicit omit: | |
467 | var MyRecord record3 := valueof(t_MyRecord2_io(7, 8, subRecord)); // 7,8,1,2 | |
468 | if (record3 == { 7, 8, { 1, 2 } }) { setverdict(pass) } else { setverdict(fail) } // parent is not modified anymore... | |
469 | var MyRecord record4 := valueof(t_MyRecord2_io2(0, 0, subRecord)); // 0,0,1,2 | |
470 | if (record4 == { 0, 0, { 1, 2 } }) { setverdict(pass) } else { setverdict(fail) } // ...unless it's requested | |
471 | } | |
472 | ||
473 | // HQ30261: "Implicit omit doesn't work for modulepar default values" | |
474 | type record MyOwnRecord { integer f1, integer f2 optional } | |
475 | ||
476 | modulepar MyOwnRecord tsp_MyOwnRecord_init := { f1 := 1 } with { optional "implicit omit" } | |
477 | modulepar MyOwnRecord tsp_MyOwnRecord_empty with { optional "implicit omit" } | |
478 | ||
479 | testcase tc_HQ30261() runs on O { | |
480 | if (match(tsp_MyOwnRecord_init, { 1, omit })) { setverdict(pass) } else { setverdict(fail) } | |
481 | if (not isbound(tsp_MyOwnRecord_empty.f1) and tsp_MyOwnRecord_empty.f2 == omit) { setverdict(pass) } else { setverdict(fail) } | |
482 | } | |
483 | ||
484 | // Implicit omit for fields of records embedded in a union | |
485 | type union Something { | |
486 | Outer outer, | |
487 | Inner inner, | |
488 | octetstring os | |
489 | } | |
490 | ||
491 | type record Outer { | |
492 | integer i, | |
493 | Inner inner optional | |
494 | } | |
495 | ||
496 | type record Inner { | |
497 | float f, | |
498 | charstring cs optional | |
499 | } | |
500 | ||
501 | const Something c_something_value := { | |
502 | outer := { | |
503 | i := 10, | |
504 | inner := { | |
505 | f := 7.1 | |
506 | } | |
507 | } | |
508 | } with { optional "implicit omit" } | |
509 | ||
510 | template Something t_something_target := { | |
511 | outer := { | |
512 | i := 10, | |
513 | inner := { | |
514 | f := 7.1, | |
515 | cs := omit | |
516 | } | |
517 | } | |
518 | } | |
519 | ||
520 | testcase tc_io_embedded() runs on O | |
521 | { | |
522 | if (match(c_something_value, t_something_target)) { setverdict(pass); } | |
523 | else { setverdict(fail, c_something_value); } | |
524 | } | |
525 | ||
526 | // Implicit omit specified with the not used symbol (-) with the value list notation | |
527 | type record of Outer RoO; | |
528 | ||
529 | const RoO c_notused_value := { | |
530 | { 3, - }, | |
531 | { 4, { 3.9, - } } | |
532 | } with { optional "implicit omit" } | |
533 | ||
534 | template RoO t_notused_target := { | |
535 | { 3, omit }, | |
536 | { 4, { 3.9, omit } } | |
537 | } with { optional "implicit omit" } | |
538 | ||
539 | testcase tc_io_notused() runs on O | |
540 | { | |
541 | if (match(c_notused_value, t_notused_target)) { setverdict(pass); } | |
542 | else { setverdict(fail, c_notused_value); } | |
543 | } | |
544 | ||
545 | control { | |
546 | execute(tc12()); | |
547 | execute(tc1ab()); | |
548 | execute(tc2ab()); | |
549 | ||
550 | execute(tc_11()); | |
551 | execute(tc_21()); | |
552 | ||
553 | execute(tc_22()); | |
554 | execute(tc_23()); | |
555 | execute(tc_24()); | |
556 | execute(tc_25()); | |
557 | ||
558 | execute(tc62()); | |
559 | ||
560 | log("MyTemplate1ln = ",MyTemplate1ln); | |
561 | log("MyTemplate1an = ",MyTemplate1an); | |
562 | log("MyTemplate1 = ",MyTemplate1); | |
563 | log("MyTemplate2 = ",MyTemplate2); | |
564 | log("MyTemplate1a = ",MyTemplate1a); | |
565 | log("MyTemplate1b = ",MyTemplate1b); | |
566 | log("MyTemplate2a = ",MyTemplate2a); | |
567 | log("MyTemplate2b = ",MyTemplate2b); | |
568 | log("MyTemplate11 = ",MyTemplate11); | |
569 | log("MyTemplate21 = ",MyTemplate21); | |
570 | log("MyTemplate22 = ",MyTemplate22); | |
571 | log("MyTemplate23 = ",MyTemplate23); | |
572 | log("MyTemplate24 = ",MyTemplate24); | |
573 | log("MyTemplate25 = ",MyTemplate25); | |
574 | ||
575 | log("x1=", x1); | |
576 | log("x2=", x2); | |
577 | log("x3=", x3); | |
578 | ||
579 | execute(tc_iompar_recset()) | |
580 | execute(tc_iompar_uni()) | |
581 | execute(tc_iompar_listarr()) | |
582 | execute(tc_HP93133()) | |
583 | execute(tc_HQ30261()) | |
584 | ||
585 | execute(tc_io_embedded()); | |
586 | execute(tc_io_notused()); | |
587 | } | |
588 | with { | |
589 | optional "implicit omit" | |
590 | } | |
591 | ||
592 | } | |
593 |