**** Merged from MCS ****
[mono-project.git] / mcs / mbas / Test / tests / AccessibilityB.vb
blobb8a6a9c832c3e9c91232ff24894e2e51318600b0
1 Imports System
2 Class C1
3 Public a As Integer=20
4 Private b As Integer=30
5 Friend c As Integer=40
6 Protected d As Integer=50
7 Public Sub S1() ' All data members of the class should be accessible
8 Try
10 If a<>20 Then
11 Throw New Exception("#A1-Accessibility:Failed-error accessing value of public data member frm same class")
12 End If
13 Catch e As Exception
14 Console.WriteLine(e.Message)
15 End Try
17 Try
18 If b<>30 Then
19 Throw New Exception("#A2-Accessibility:Failed-error accessing value of private data member from same class")
20 End If
21 Catch e As Exception
22 Console.WriteLine(e.Message)
23 End Try
25 Try
27 If c<>40 Then
28 Throw New Exception("#A3-Accessibility:Failed-error accessing value of friend data member from same class")
29 End If
30 Catch e As Exception
31 Console.WriteLine(e.Message)
32 End Try
34 Try
35 If d<>50 Then
36 Throw New Exception("#A4-Accessibility:Failed-error accessing value of protected data member from same class")
37 End If
38 Catch e As Exception
39 Console.WriteLine(e.Message)
40 End Try
42 S2()
43 End Sub
44 Private Sub S2()
45 End Sub
46 End Class
47 Class C2
48 Inherits C1
49 Public Sub DS1() 'All data members except private members should be accessible
50 Try
51 If a<>20 Then
52 Throw New Exception("#A5-Accessibility:Failed-error accessing value of public data member from derived class")
53 End If
54 Catch e As Exception
55 Console.WriteLine(e.Message)
56 End Try
58 Try
59 If c<>40 Then
60 Throw New Exception("#A6-Accessibility:Failed-error accessing value of friend data member from derived class")
61 End If
62 Catch e As Exception
63 Console.WriteLine(e.Message)
64 End Try
66 Try
67 If d<>50 Then
68 Throw New Exception("#A7-Accessibility:Failed-error accessing value of protected data member from derived")
69 End If
70 Catch e As Exception
71 Console.WriteLine(e.Message)
72 End Try
74 End Sub
75 End Class
76 Class C3
77 Public Sub S1() 'All public and friend members should be accessible
78 Dim myC As New C1()
79 Try
80 If myC.a<>20 Then
81 Throw New Exception("#A8-Accessibility:Failed-error accessing value of public data member from another class")
82 End If
83 Catch e As Exception
84 Console.WriteLine(e.Message)
85 End Try
87 Try
88 If myC.c<>40 Then
89 Throw New Exception("#A9-Accessibility:Failed-error accessing value of friend data member from another class")
90 End If
91 Catch e As Exception
92 Console.WriteLine(e.Message)
93 End Try
95 End Sub
96 End Class
97 Module Accessibility
98 Sub Main()
99 Dim myC1 As New C1()
100 myC1.S1()
102 If myC1.a<>20 Then
103 Throw New Exception("#A10-Accessibility:Failed-error accessing value of public data member form another module")
104 End If
105 Catch e As Exception
106 Console.WriteLine(e.Message)
107 End Try
109 Dim myC2 As New C2()
110 myC2.DS1()
111 Dim myC3 As New C3()
112 myC3.S1()
113 End Sub
114 End Module