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
28 public struct TestStruct1
33 public struct TestStruct2
39 public struct TestStruct3
47 return TestDriver.RunTests (typeof (Tests));
50 static void reg_struct(TestStruct1 regStruct)
55 static int test_0_regstruct ()
66 static int reg_struct_ret(TestStruct2 regStruct)
71 static int test_0_reg_return ()
76 if (reg_struct_ret(myStruct) == 42)
81 static int spill_regs (int a, int b, int c, int d, int e, int f)
86 static int test_0_spill_regs ()
88 if (spill_regs (1, 2, 3, 4, 5, 6) == 6)
94 static TestStruct3 spill_struct (TestStruct3 regStruct, int value)
100 static TestStruct3 ret_big_struct (int value_a, int value_c)
102 TestStruct3 regStruct = new TestStruct3();
103 regStruct.a = value_a;
104 regStruct.c = value_c;
108 static int spill_struct_void (TestStruct3 regStruct)
110 if (regStruct.c == 255)
116 static int receive_spill_struct (TestStruct2 regStruct)
118 if (regStruct.b == 181)
124 static int pass_spill_struct_big (int a, int b, int c, int d, int e, TestStruct3 regStruct)
127 retVal = receive_spill_struct_big(regStruct);
131 static int receive_spill_struct_big (TestStruct3 regStruct)
133 if (regStruct.c == 999)
139 static int receive_struct_spill (int a, int b, int c, int d, int e, TestStruct2 regStruct)
141 if (regStruct.b == 181)
147 static int receive_struct_spill_big (int a, int b, int c, int d, int e, TestStruct3 regStruct)
149 if (regStruct.c == 999)
155 static int pass_spill_struct (int a, int b, int c, int d, int e, TestStruct2 regStruct)
158 retVal = receive_spill_struct(regStruct);
162 static int pass_struct_spill (TestStruct2 regStruct)
165 retVal = receive_struct_spill(1,2,3,4,5,regStruct);
169 static int pass_struct_spill_big(TestStruct3 regStruct)
172 retVal = receive_struct_spill_big(1,2,3,4,5,regStruct);
176 static int pass_spill_struct_spill (int a, int b, int c, int d, int e, TestStruct2 regStruct)
179 retVal = receive_struct_spill(a,b,c,d,e,regStruct);
183 static int pass_spill_struct_spill_big(int a, int b, int c, int d, int e, TestStruct3 regStruct)
186 retVal = receive_struct_spill_big(a,b,c,d,e,regStruct);
190 static int test_0_spill ()
192 TestStruct3 myStruct;
196 myStruct = spill_struct(myStruct, 99);
197 if (myStruct.c == 99)
202 static int test_0_spill_void ()
204 TestStruct3 myStruct;
208 return (spill_struct_void(myStruct));
211 static int spill_struct_ret (TestStruct3 regStruct)
213 return (regStruct.c);
217 static int test_0_spill_ret ()
219 TestStruct3 myStruct;
223 if (spill_struct_ret(myStruct) == 69)
228 static TestStruct2 struct_ret(TestStruct2 regStruct)
235 static int test_0_struct_ret ()
237 TestStruct2 myStruct;
240 myStruct = struct_ret(myStruct);
241 if (myStruct.b == 72)
247 static float TestSingle (float a, float b, float c)
252 static int test_0_TestSingle ()
254 float a = 3F; float b = 4.5F; float c = 900F;
255 if (TestSingle(a, b, c) == b)
261 static int test_0_pass_spill ()
263 TestStruct2 myStruct;
266 return (pass_spill_struct (1, 2, 3, 4, 5, myStruct));
269 static int test_0_pass_spill_big ()
271 TestStruct3 myStruct;
275 return (pass_spill_struct_big (1, 2, 3, 4, 5, myStruct));
278 static int test_0_pass_struct_spill ()
280 TestStruct2 myStruct;
283 return (pass_struct_spill (myStruct));
286 static int test_0_pass_struct_spill_big ()
288 TestStruct3 myStruct;
292 return (pass_struct_spill_big (myStruct));
295 static int test_0_pass_ret_big_struct ()
297 TestStruct3 myStruct;
298 myStruct = ret_big_struct(10,132);
299 if (myStruct.c == 132)
305 static int test_0_pass_spill_struct_spill ()
307 TestStruct2 myStruct;
310 return (pass_spill_struct_spill (1,2,3,4,5,myStruct));
313 static int test_0_pass_spill_struct_spill_big ()
315 TestStruct3 myStruct;
319 return (pass_spill_struct_spill_big (1,2,3,4,5,myStruct));
322 static long pass_long_odd (int a, long b)
327 static int test_0_pass_long_odd ()
331 if (pass_long_odd(a,b) == 9000)
337 static float pass_double_ret_float(double a)
344 static int test_0_pass_double_ret_float ()
348 if (pass_double_ret_float(a) == b)
354 static double pass_float_ret_double(float a)
361 static int test_0_pass_float_ret_double ()
365 if (pass_float_ret_double(a) == b)