Merge all static runtime libs into libmono-static.
[mono.git] / mcs / tests / test-304.cs
1 using System;
2 using System.Collections;
3
4 using C = A.D;
5
6
7 class A
8 {
9         internal class D { }
10         public class B
11         {
12                 class C { }
13
14                 public B() {
15                         string error = "";
16
17                         if (typeof (C) != typeof (A.B.C))
18                                 error += " 'typeof' keyword,";
19
20                         object o0 = new C ();
21                         if (o0.GetType() != typeof (A.B.C))
22                                 error += " 'new' keyword,";
23
24                         C o1 = new C ();
25                         if (o1.GetType () != typeof (A.B.C))
26                                 error += " type declaration,";
27
28                         object o2 = new A.B.C ();
29                         if (!(o2 is C))
30                                 error += " 'is' keyword,";
31
32                         object o3 = o2 as C;
33                         if (o3 == null)
34                                 error += " 'as' keyword,";
35
36                         try {
37                                 object o4 = (C) o2;
38                         }
39                         catch {
40                                 error += " type cast,";
41                         }
42
43                         try {
44                                 object o5 = (C) (o2);
45                         }
46                         catch {
47                                 error += " invocation-or-cast,";
48                         }
49
50                         object o6 = new C [1];
51
52                         if (o6.GetType ().GetElementType () != typeof (A.B.C))
53                                 error += " array creation,";
54
55                         if (typeof (C []).GetElementType () != typeof (A.B.C))
56                                 error += " composed cast (array),";
57
58                         ArrayList a = new ArrayList ();
59                         a.Add (new A.B.C ());
60
61                         try {
62                                 foreach (C c in a)
63                                 { 
64                                 }
65                         }
66                         catch {
67                                 error += " 'foreach' statement,";
68                         }
69
70                         if (error.Length != 0)
71                                 throw new Exception ("The following couldn't resolve C as A+B+C:" + error);
72                 }
73         }
74
75         public static void Main()
76         {
77                 object o = new A.B();
78         }
79 }