2007-10-19 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / tests / test-232.cs
index 119d43b3ce74faf4e6846a0df7e2b6cadde3bc1f..cf3a426fa33a822afe3443a2aa15e82d3a7679ad 100644 (file)
@@ -3,8 +3,15 @@ using System.Reflection;
 
 public class CtorInfoTest
 {
+       enum E
+       {
+               A = 0,
+               B = 1
+       }
+       
        public static void Main(string[] args)
        {
+
                // uses static initialization
                int[] iarray = // int array, int constants
                {
@@ -17,6 +24,25 @@ public class CtorInfoTest
                        6,
                };
                
+               object[] oarray = // int array, int constants
+               {
+                       0,
+                       E.A,
+                       null,
+                       "A",
+                       new int (),
+                       1.1,
+                       -2m,
+               };
+               
+               object[] ooarray =
+               {
+                       null,
+                       new int[] { 0, 0 },
+                       0,
+                       new object[0],
+               };
+               
                // mcs used to throw with 7 or more elements in the array initializer
                ConstructorInfo[] ciarray = // ref array, null constants
                {
@@ -65,6 +91,7 @@ public class CtorInfoTest
 
                IConvertible[] lcarray = // boxed integer constants
                {
+                       0,
                        1,
                        2,
                        3,
@@ -74,7 +101,8 @@ public class CtorInfoTest
                        7,
                };
                
-               AttributeTargets[] atarray = // enum constants
+
+               System.Enum[] eatarray = // boxed enum constants
                {
                        AttributeTargets.Assembly,
                        AttributeTargets.Module,
@@ -93,23 +121,53 @@ public class CtorInfoTest
                        AttributeTargets.All,
                };
 
-               System.Enum[] eatarray = // boxed enum constants
+               E[] atarray = // enum constants
                {
-                       AttributeTargets.Assembly,
-                       AttributeTargets.Module,
-                       AttributeTargets.Class,
-                       AttributeTargets.Struct,
-                       AttributeTargets.Enum,
-                       AttributeTargets.Constructor,
-                       AttributeTargets.Method,
-                       AttributeTargets.Property,
-                       AttributeTargets.Field,
-                       AttributeTargets.Event,
-                       AttributeTargets.Interface,
-                       AttributeTargets.Parameter,
-                       AttributeTargets.Delegate,
-                       AttributeTargets.ReturnValue,
-                       AttributeTargets.All,
+                       E.A,
+                       E.B
                };
+
+               
+               string[] smarray = // string array, mixture
+               {
+                       null,
+                       "a"
+               };
+
+               for (int i = 0; i < iarray.Length; ++i)
+                       Assert (i, iarray [i]);
+               
+               for (int i = 0; i < ciarray.Length; ++i)
+                       Assert (null, ciarray [i]);
+               
+               Assert ("a", scarray [0]);
+
+               for (int i = 0; i < snarray.Length; ++i)
+                       Assert (null, snarray [i]);
+
+               for (decimal i = 0; i < darray.Length; ++i)
+                       Assert (i, darray [(int)i]);
+
+               for (int i = 0; i < lcarray.Length; ++i)
+                       Assert (i, lcarray [i]);
+
+               Assert (E.A, atarray [0]);
+               Assert (E.B, atarray [1]);
+               
+               Assert (AttributeTargets.Assembly, eatarray [0]);
+               Assert (AttributeTargets.Class, eatarray [2]);
+               
+               Assert (null, smarray [0]);
+               Assert ("a", smarray [1]);
+               
+       }
+       
+       static void Assert (object expected, object value)
+       {
+               if (expected == null && value == null)
+                       return;
+               
+               if (!expected.Equals (value))
+                       Console.WriteLine ("ERROR {0} != {1}", expected, value);
        }
 }