cleol
[mcs.git] / tests / test-304.cs
blob79a86fa217d9401081db69d7d4c20526ee5f6291
1 using System;
2 using System.Collections;
4 using C = A.D;
7 class A
9 internal class D { }
10 public class B
12 class C { }
14 public B() {
15 string error = "";
17 if (typeof (C) != typeof (A.B.C))
18 error += " 'typeof' keyword,";
20 object o0 = new C ();
21 if (o0.GetType() != typeof (A.B.C))
22 error += " 'new' keyword,";
24 C o1 = new C ();
25 if (o1.GetType () != typeof (A.B.C))
26 error += " type declaration,";
28 object o2 = new A.B.C ();
29 if (!(o2 is C))
30 error += " 'is' keyword,";
32 object o3 = o2 as C;
33 if (o3 == null)
34 error += " 'as' keyword,";
36 try {
37 object o4 = (C) o2;
39 catch {
40 error += " type cast,";
43 try {
44 object o5 = (C) (o2);
46 catch {
47 error += " invocation-or-cast,";
50 object o6 = new C [1];
52 if (o6.GetType ().GetElementType () != typeof (A.B.C))
53 error += " array creation,";
55 if (typeof (C []).GetElementType () != typeof (A.B.C))
56 error += " composed cast (array),";
58 ArrayList a = new ArrayList ();
59 a.Add (new A.B.C ());
61 try {
62 foreach (C c in a)
66 catch {
67 error += " 'foreach' statement,";
70 if (error.Length != 0)
71 throw new Exception ("The following couldn't resolve C as A+B+C:" + error);
75 public static void Main()
77 object o = new A.B();