Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-232.cs
1 using System;
2 using System.Reflection;
3
4 public class CtorInfoTest
5 {
6         enum E
7         {
8                 A = 0,
9                 B = 1
10         }
11         
12         public static void Main(string[] args)
13         {
14
15                 // uses static initialization
16                 int[] iarray = // int array, int constants
17                 {
18                         0,
19                         1,
20                         2,
21                         3,
22                         4,
23                         5,
24                         6,
25                 };
26                 
27                 object[] oarray = // int array, int constants
28                 {
29                         0,
30                         E.A,
31                         null,
32                         "A",
33                         new int (),
34                         1.1,
35                         -2m,
36                 };
37                 
38                 object[] ooarray =
39                 {
40                         null,
41                         new int[] { 0, 0 },
42                         0,
43                         new object[0],
44                 };
45                 
46                 // mcs used to throw with 7 or more elements in the array initializer
47                 ConstructorInfo[] ciarray = // ref array, null constants
48                 {
49                         null,
50                         null,
51                         null,
52                         null,
53                         null,
54                         null,
55                         null,
56                 };
57
58                 string[] scarray = // string array, string constants
59                 {
60                         "a",
61                         "b",
62                         "c",
63                         "d",
64                         "e",
65                         "f",
66                         "g",
67                 };
68
69                 string[] snarray = // string array, null constants
70                 {
71                         null,
72                         null,
73                         null,
74                         null,
75                         null,
76                         null,
77                         null,
78                 };
79
80                 decimal[] darray = // decimal constants
81                 {
82                         0M,
83                         1M,
84                         2M,
85                         3M,
86                         4M,
87                         5M,
88                         6M,
89                         7M,
90                 };
91
92                 IConvertible[] lcarray = // boxed integer constants
93                 {
94                         0,
95                         1,
96                         2,
97                         3,
98                         4,
99                         5,
100                         6,
101                         7,
102                 };
103                 
104
105                 System.Enum[] eatarray = // boxed enum constants
106                 {
107                         AttributeTargets.Assembly,
108                         AttributeTargets.Module,
109                         AttributeTargets.Class,
110                         AttributeTargets.Struct,
111                         AttributeTargets.Enum,
112                         AttributeTargets.Constructor,
113                         AttributeTargets.Method,
114                         AttributeTargets.Property,
115                         AttributeTargets.Field,
116                         AttributeTargets.Event,
117                         AttributeTargets.Interface,
118                         AttributeTargets.Parameter,
119                         AttributeTargets.Delegate,
120                         AttributeTargets.ReturnValue,
121                         AttributeTargets.All,
122                 };
123
124                 E[] atarray = // enum constants
125                 {
126                         E.A,
127                         E.B
128                 };
129
130                 
131                 string[] smarray = // string array, mixture
132                 {
133                         null,
134                         "a"
135                 };
136
137                 for (int i = 0; i < iarray.Length; ++i)
138                         Assert (i, iarray [i]);
139                 
140                 for (int i = 0; i < ciarray.Length; ++i)
141                         Assert (null, ciarray [i]);
142                 
143                 Assert ("a", scarray [0]);
144
145                 for (int i = 0; i < snarray.Length; ++i)
146                         Assert (null, snarray [i]);
147
148                 for (decimal i = 0; i < darray.Length; ++i)
149                         Assert (i, darray [(int)i]);
150
151                 for (int i = 0; i < lcarray.Length; ++i)
152                         Assert (i, lcarray [i]);
153
154                 Assert (E.A, atarray [0]);
155                 Assert (E.B, atarray [1]);
156                 
157                 Assert (AttributeTargets.Assembly, eatarray [0]);
158                 Assert (AttributeTargets.Class, eatarray [2]);
159                 
160                 Assert (null, smarray [0]);
161                 Assert ("a", smarray [1]);
162                 
163         }
164         
165         static void Assert (object expected, object value)
166         {
167                 if (expected == null && value == null)
168                         return;
169                 
170                 if (!expected.Equals (value))
171                         Console.WriteLine ("ERROR {0} != {1}", expected, value);
172         }
173 }