conformance_test/positive_tests added
[deliverable/titan.core.git] / conformance_test / positive_tests / 15_templates / 1508_template_restrictions / Sem_1508_TemplateRestrictions_036.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 * Adrien Kirjak – initial implementation
10 *
11 ** @version 0.0.1
12 ** @purpose 1:15.8, Ensure that the restrictiveness of parameters template(omit)->template(present) is handled correctly.
13 ** @verdict pass accept, ttcn3verdict:pass
14 *****************************************************************/
15
16 // ATTENTION: valid for TTCN-3:2013 (ETSI ES 201 873-1 V4.5.1) and newer
17 // Older versions of the core languate standard didn't allow this type of
18 // modification because of restriction 15.8.c.
19
20 /*
21 Pro opinion:
22 Test an intentional change made on the request of the STF160 in TTCN-3:2013. In particular, restriction 15.8.c was taken away from the core language specification (as marked in test case comments). This restriction did indeed mean that the tests would behave as you described, thus producing an error. However, with the restriction missing, the tests are perfectly valid. I also do not understand why you claim that it would not be possible to instantiate super-templates in these cases. Restrictions are always related to actual values and if the values satisfy both restrictions (parent and modified), there's no problem at all. And this is exactly what these test intend to verify.
23 Besides, the core language specification does not say that the parameters must be the same. There's a rule saying that the parameters shall not be omitted. It is rather unfortunate wording, because it might be interpreted in several ways. There's a CR 6692 regarding this issue.
24
25 Contra opinion
26 The problem is with the semantics of modified templates. For every actual parameter list, first, the template-to-be-modified is implicitly instantiated and then modified by the given modifications. If the template-to-be-modified is not defined for the actual parameters, then neither is the modified one. Of course, you are right in that this restriction could be applied for actual parameters only and need not be checked at the template-level already. However, it does not make sense to lessen the template restriction of a parameter, as implicitly, it still keeps the stronger restriction (because of the modification-semantics). Therefore, it is misleading to SEEMINGLY allow a template(present) parameter for a template where the super-template has a template(value) parameter. If allowed, the user might use a non-value template as an actual parameter and then get a runtime error, even though the template-restriction matched the one in the formal parameter of the template. Therefore, we interpret the standard in such a way that the inheritance of the parameters includes the inheritance of both the types and the template restrictions of the inherited parameters. Strengthening of template restrictions would indeed not be a problem. Lessening is.
27
28 */
29
30 module Sem_1508_TemplateRestrictions_036 {
31
32 type component GeneralComp { }
33
34 type record ExampleType {
35 integer a,
36 boolean b optional
37 }
38
39 template(present) ExampleType m_baseTemplate(template(present) integer p_myInt) := {
40 a := p_myInt,
41 b := true
42 }
43
44 template(present) ExampleType m_modifiedTemplate(template integer p_myInt) modifies m_baseTemplate := {
45 a := 21
46 }
47
48 testcase TC_Sem_1508_TemplateRestrictions_036() runs on GeneralComp {
49 if (match(valueof(m_modifiedTemplate(1).a), 21) and
50 match(valueof(m_modifiedTemplate(1).b), true)
51 ) {
52 setverdict(pass);
53 } else {
54 setverdict(fail);
55 }
56 }
57
58 control{
59 execute(TC_Sem_1508_TemplateRestrictions_036());
60 }
61 }
This page took 0.080322 seconds and 5 git commands to generate.