Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2006-04-05 00:57:13 +0400
committerMarek Safar <marek.safar@gmail.com>2006-04-05 00:57:13 +0400
commitc09387c13d274a0b28b1ae90a577fc41761b817a (patch)
tree62bda1ab292daa3e445caa7e639cabd807fa191a /mcs/tests/test-232.cs
parentcdbcc6578b4b942f440a4fd101b70f0061d88d66 (diff)
2006-04-04 Marek Safar <marek.safar@seznam.cz>
* constant.cs (Constant.IsDefaultInitializer): New method. * class.cs: Updated. * expression.cs (ArrayCreation.CheckIndices): Add an optimization to don't re-initialize default values. It saves KBs almost for every assembly. Thanks Zoltan for the idea. (ArrayCreation.ResolveInitializers): Renamed from ValidateInitializers. (ArrayCreation.DoResolve): Resolve only once. (ArrayCreation.Emit): Emit static initializer only when it is faster. (ArrayCreation.GetAttributableValue): Cope with optimized values. svn path=/trunk/mcs/; revision=59040
Diffstat (limited to 'mcs/tests/test-232.cs')
-rw-r--r--mcs/tests/test-232.cs92
1 files changed, 75 insertions, 17 deletions
diff --git a/mcs/tests/test-232.cs b/mcs/tests/test-232.cs
index 119d43b3ce7..cf3a426fa33 100644
--- a/mcs/tests/test-232.cs
+++ b/mcs/tests/test-232.cs
@@ -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);
}
}