Last sync 2016.04.01
[deliverable/titan.core.git] / regression_test / visibility / module1.ttcn
CommitLineData
970ed795 1/******************************************************************************
d44e3c4f 2 * Copyright (c) 2000-2016 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
d44e3c4f 7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Czerman, Oliver
11 * Szabados, Kristof
12 *
970ed795
EL
13 ******************************************************************************/
14module module1
15{
16
17public modulepar charstring ts_m1:="public";
18private modulepar charstring ts_m2:="private";
19friend modulepar charstring ts_m3:="friend";
20
21friend module Visibility, module2;
22
23private import from module2 all;//OK
24private import from module3 all;//OK
25private import from module4 all;//OK
26//public import from module2 all;//NOK
27//friend import from module2 all;//NOK
28
29const module2Type akarmi1 := 1; //OK, type is implicitly public
30const module2TypePublic akarmi2 := 2; //OK, type is explicitly public
31const module2TypeFriend akarmi3 := 3; //OK, module1 is friend of module2
32//const module2TypePrivate akarmi4 := 4; //NOK, module2TypePrivate is private to module2
33
34group g_MyGroup{
35 const module3Type akarmi5 := 5; //OK, type is implicitly public
36 const module3TypePublic akarmi6 := 6; //OK, type is explicitly public
37 //const module3TypeFriend akarmi7 := 7; //NOK, module1 is NOT a friend of module3
38 //const module3TypePrivate akarmi8 := 8; //NOK, module2TypePrivate is private to module2
39}
40
41function MyFunc1() runs on Lib4_CT {} //OK
42function MyFunc2() runs on Lib4Friend_CT {} //OK, module1 is friend for module4
43//function MyFunc3() runs on Lib4Private_CT {} //NOK, the *name* Lib4Private_CT is not
44 //visible for module1, thus fails at checking the runs on clause, whatever is the content!
45
46
47function f_set2_Lib4_1() runs on Lib4_CT { v_Lib4_1 := 0 } //OK
48function f_set2_Lib4_2() runs on Lib4_CT { v_Lib4_2 := 0 } //OK
49function f_set2_Lib4_3() runs on Lib4_CT { v_Lib4_3 := 0 } //OK
50function f_set2_Lib4Friend_1() runs on Lib4Friend_CT { v_Lib4Friend_1 := 0 } //OK
51function f_set2_Lib4Friend_2() runs on Lib4Friend_CT { v_Lib4Friend_2 := 0 } //OK
52function f_set2_Lib4Friend_3() runs on Lib4Friend_CT { v_Lib4Friend_3 := 0 } //OK
53
54
55type component User_CT extends Lib4_CT {};
56function f_set3_Lib4_1() runs on User_CT { v_Lib4_1 := 0 } //OK
57function f_set3_Lib4_2() runs on User_CT { v_Lib4_2 := 0 } //OK
58//function f_set3_Lib4_3() runs on User_CT { v_Lib4_3 := 0 } //NOK, v_Lib4_3 is private, can be used
59//in functions with "Lib4_CT" in their runs on (but not in children)
60
61//in short: visibility of the component type definition (name) and allowed use of the component
62//type definitions are two different things. Component type visibility is checked when checking
63//the runs on clause. Component definition visibility is checked (after a successful runs on
64//check), when the definition is used within the body of the function
65
66
67//All setter functions of module4 are public, hence can be called from any function
68//with a compatible runs on clause
69function f_MyFunc_1() runs on User_CT { f_set_Lib4_1() } //OK
70function f_MyFunc_2() runs on User_CT { f_set_Lib4_2() } //OK
71function f_MyFunc_3() runs on User_CT { f_set_Lib4_3() } //OK
72
73type component UserFriend_CT extends Lib4Friend_CT {}; //OK
74function f_MyFuncFriend_1() runs on UserFriend_CT { f_set_Lib4Friend_1() } //OK
75function f_MyFuncFriend_2() runs on UserFriend_CT { f_set_Lib4Friend_2() } //OK
76function f_MyFuncFriend_3() runs on UserFriend_CT { f_set_Lib4Friend_3() } //OK
77
78
79//type component UserPrivate_CT extends Lib4Private_CT {}; //NOK, the name Lib4Private_CT is not
80 //visible in module1
81//function MyFunc() {
82//var Lib4Private_CT v_Lib4Private := Lib4Private_CT.create; //NOK, the name Lib4Private_CT is not
83 //visible in module1
84//}
85//function f_MyFuncPrivate_1() runs on UserPrivate_CT { f_set_Lib4Private_1() } //NOK, UserPrivate_CT has an error
86//function f_MyFuncPrivate_2() runs on UserPrivate_CT { f_set_Lib4Private_2() } //NOK, UserPrivate_CT has an error
87//function f_MyFuncPrivate_3() runs on UserPrivate_CT { f_set_Lib4Private_3() } //NOK, UserPrivate_CT has an error
88
89control{}
90
91} // end of module1
This page took 0.026731 seconds and 5 git commands to generate.