2 using System.Reflection;
5 * Regression tests for the mono JIT.
7 * Each test needs to be of the form:
9 * static int test_<result>_<name> ();
11 * where <result> is an integer (the value that needs to be returned by
12 * the method to make it pass.
13 * <name> is a user-displayed name used to identify the test.
15 * The tests can be driven in two ways:
16 * *) running the program directly: Main() uses reflection to find and invoke
17 * the test methods (this is useful mostly to check that the tests are correct)
18 * *) with the --regression switch of the jit (this is the preferred way since
19 * all the tests will be run with optimizations on and off)
21 * The reflection logic could be moved to a .dll since we need at least another
22 * regression test file written in IL code to have better control on how
29 return TestDriver.RunTests (typeof (Tests));
32 public static int test_10_create () {
33 int[] a = new int [10];
37 public static int test_0_unset_value () {
38 int[] a = new int [10];
42 public static int test_3_set_value () {
43 int[] a = new int [10];
48 public static int test_0_char_array_1 () {
50 char[] tmp = new char [20];
51 char[] digitLowerTable = new char[16];
52 tmp[0] = digitLowerTable[-(value % 10)];
56 public static int test_0_char_array_2 () {
58 char[] tmp = new char [20];
59 char[] digitLowerTable = new char[16];
60 tmp[0] = digitLowerTable[value % 10];
64 public static int test_0_char_array_3 () {
66 char[] tmp = new char [20];
67 char[] digitLowerTable = new char[16];
68 tmp [0] = digitLowerTable[value & 15];
72 public unsafe static int test_0_byte_array () {
73 byte [] src = new byte [8];
75 byte *dst = (byte *)&ret;
78 dst[0] = src[4 + start];
83 public static int test_0_set_after_shift () {
84 int [] n = new int [1];
87 n [0] = 100 + (1 << (16 - b));
95 /* Regression test for #30073 */
96 public static int test_0_newarr_emulation () {
99 double [] arr = new double [(int)d];
104 private Int32[] m_array = new int [10];
106 void setBit (int bitIndex, bool value) {
107 int index = bitIndex/32;
108 int shift = bitIndex%32;
110 Int32 theBit = 1 << shift;
112 m_array[index] |= theBit;
114 m_array[index] &= ~theBit;
117 bool getBit (int bitIndex) {
118 int index = bitIndex/32;
119 int shift = bitIndex%32;
121 Int32 theBit = m_array[index] & (1 << shift);
122 return (theBit == 0) ? false : true;
126 public static int test_1_bit_index () {
127 Tests t = new Tests ();
141 int [] ma = new int [56];
142 const int MBIG = int.MaxValue;
145 for (int k = 1; k < 5; k++) {
146 for (int i = 1; i < 56; i++) {
147 ma [i] -= ma [1 + (i + 30) % 55];
155 public static int test_2_regalloc () {
156 helper1 h = new helper1 ();
160 public static int test_0_stelemref_1 () {
161 object [] o = new object [1];
167 public static int test_0_stelemref_2 () {
168 object [] o = new object [1];
175 class Face : IFace {}
177 public static int test_0_stelemref_3 () {
178 object [] o = new IFace [1];
184 public static int test_0_stelemref_4 () {
185 object [][] o = new object [5] [];
186 o [0] = new object [5];
191 public static int test_0_multi_dimension_arrays () {
194 byte[,] a1 = new byte [10, 10];
195 for (int i = 0; i < 10; ++i)
198 for (int i = 0; i < 10; ++i)
203 sbyte[,] a2 = new sbyte [10, 10];
204 for (int i = 0; i < 10; ++i)
205 a2 [i, i] = (sbyte)i;
207 for (int i = 0; i < 10; ++i)
212 short[,] a3 = new short [10, 10];
213 for (int i = 0; i < 10; ++i)
214 a3 [i, i] = (short)i;
216 for (int i = 0; i < 10; ++i)
221 ushort[,] a4 = new ushort [10, 10];
222 for (int i = 0; i < 10; ++i)
223 a4 [i, i] = (ushort)i;
225 for (int i = 0; i < 10; ++i)
230 int[,] a5 = new int [10, 10];
231 for (int i = 0; i < 10; ++i)
234 for (int i = 0; i < 10; ++i)
239 uint[,] a6 = new uint [10, 10];
240 for (int i = 0; i < 10; ++i)
243 for (int i = 0; i < 10; ++i)
244 sum += (int)a6 [i, i];
248 long[,] a7 = new long [10, 10];
249 for (int i = 0; i < 10; ++i)
252 for (int i = 0; i < 10; ++i)
253 sum += (int)a7 [i, i];
257 ulong[,] a8 = new ulong [10, 10];
258 for (int i = 0; i < 10; ++i)
259 a8 [i, i] = (ulong)i;
261 for (int i = 0; i < 10; ++i)
262 sum += (int)a8 [i, i];
266 float[,] a9 = new float [10, 10];
267 for (int i = 0; i < 10; ++i)
268 a9 [i, i] = (float)i;
270 for (int i = 0; i < 10; ++i)
271 sum += (int)a9 [i, i];
275 double[,] a10 = new double [10, 10];
276 for (int i = 0; i < 10; ++i)
279 for (int i = 0; i < 10; ++i)
280 sum += (int)a10 [i, i];
284 object[,] a11 = new object [10, 10];
285 object o = new Object ();
286 for (int i = 0; i < 10; ++i)
288 for (int i = 0; i < 10; ++i)
295 public static int test_0_bug_71454 () {
296 int[,] a = new int[4,4];
297 int[,] b = new int[4,4];
298 for(int i = 0; i < 4; ++i) {
304 public static int test_0_interface_array_cast () {
306 object [] a = new ICloneable [2];
307 ICloneable [] b = (ICloneable [])a;
315 public static Foo[][] foo;
318 public static int test_0_regress_74549 () {
323 public static int test_0_regress_75832 () {
324 int[] table = new int[] { 0, 0 };