OopNegativeSemanticTest.ttcn 2.26 KB
Newer Older
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
/******************************************************************************
 * 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:
 *   Magyari, Miklos
 *
 ******************************************************************************/

module classesNegativeSemantic { 

type component CT {
	port PT pt_PT;
}

type port PT message { inout integer; } with { extension "internal" }

type union MyUnion {
	integer a,
	charstring b
};

type class CorrectClass1 { }

type class BadInheritance extends MyUnion {

}

32
33
type class SuperClass {
	var integer vl_a;
34
	template MyUnion t_union := { a := 10 }
35
}
36
37

type class SubClass extends SuperClass {
38
	public var integer vl_b;
39
40
41
42
}

type class GrandSubClass extends SubClass {
	var integer vl_c;
43
	template MyUnion t_union2 := { nonexist := 10 }		// non-existing template member
44
45
46
47
48
49
50
51
52
53
54
55
}

type class GrandSubClass2 extends SubClass {
	var charstring vl_b;
}

type class BaseFunctionClass {
	public function f_get_one() return integer {
		return 1; 
	}
}

56
57
58
59
60
61
62
63
64
65
66
67
68
type class OuterClass {
	private var integer m_int := 0;

	class NestedClass {
		const charstring c_text := "abc";

		class InnerClass {
			private template MyUnion t_union;
			public var integer badInteger := "xyz";
		}
	}
}

69
70
const integer cg_uninitConst1;

71
72
type class SubFunctionClass extends BaseFunctionClass {  
	private const integer m_const := 1;
73
	private const integer m_uninitConst2;
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
	public function f_get_one() return integer {		// FIXME : incomplete marker
		return m_const;
	}
}

testcase tc_basicSyntax() runs on CT {
	var GrandSubClass vl_gsc := GrandSubClass.create;
	
	var integer vl_int1 := vl_gsc.vl_c;		// correct : own class member
	var integer vl_int2 := vl_gsc.vl_b;		// correct : inherited from direct parent
	var integer vl_int3 := vl_gsc.vl_a;		// correct : inherited from upper parent
	
	var charstring vl_int4 := vl_gsc.vl_d;		// incorrect : nonexisting member
	var charstring vl_int5 := vl_gsc.vl_a;		// incorrect : type mismatch
}

}