2009-02-15 Jonathan Chambers <joncham@gmail.com>
[mcs.git] / tests / test-300.cs
blob86bb5cde88a7711fb1c66a4fe05d18b5a8e88035
1 using System;
2 using System.Collections;
4 class A
6 class C { }
8 public class B
10 class C { }
12 public B() {
13 string error = "";
15 if (typeof (C) != typeof (A.B.C))
16 error += " 'typeof' keyword,";
18 object o0 = new C ();
19 if (o0.GetType() != typeof (A.B.C))
20 error += " 'new' keyword,";
22 C o1 = new C ();
23 if (o1.GetType () != typeof (A.B.C))
24 error += " local declaration,";
26 object o2 = new A.B.C ();
27 if (!(o2 is C))
28 error += " 'is' keyword,";
30 object o3 = o2 as C;
31 if (o3 == null)
32 error += " 'as' keyword,";
34 try {
35 object o4 = (C) o2;
37 catch {
38 error += " type cast,";
41 try {
42 object o5 = (C) (o2);
44 catch {
45 error += " invocation-or-cast,";
48 object o6 = new C [1];
50 if (o6.GetType ().GetElementType () != typeof (A.B.C))
51 error += " array creation,";
53 if (typeof (C []).GetElementType () != typeof (A.B.C))
54 error += " composed cast (array),";
56 ArrayList a = new ArrayList ();
57 a.Add (new A.B.C ());
59 try {
60 foreach (C c in a)
64 catch {
65 error += " 'foreach' statement,";
68 if (error.Length != 0)
69 throw new Exception ("The following couldn't resolve C as A+B+C:" + error);
73 public static void Main()
75 object o = new A.B();