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
)
100 static int spill_struct_void (TestStruct3 regStruct
)
102 if (regStruct
.c
== 255)
108 static int receive_spill_struct (TestStruct2 regStruct
)
110 if (regStruct
.b
== 181)
116 static int pass_spill_struct_big (int a
, int b
, int c
, int d
, int e
, TestStruct3 regStruct
)
119 retVal
= receive_spill_struct_big(regStruct
);
123 static int receive_spill_struct_big (TestStruct3 regStruct
)
125 if (regStruct
.c
== 999)
131 static int receive_struct_spill (int a
, int b
, int c
, int d
, int e
, TestStruct2 regStruct
)
133 if (regStruct
.b
== 181)
139 static int receive_struct_spill_big (int a
, int b
, int c
, int d
, int e
, TestStruct3 regStruct
)
141 if (regStruct
.c
== 999)
147 static int pass_spill_struct (int a
, int b
, int c
, int d
, int e
, TestStruct2 regStruct
)
150 retVal
= receive_spill_struct(regStruct
);
154 static int pass_struct_spill (TestStruct2 regStruct
)
157 retVal
= receive_struct_spill(1,2,3,4,5,regStruct
);
161 static int pass_struct_spill_big(TestStruct3 regStruct
)
164 retVal
= receive_struct_spill_big(1,2,3,4,5,regStruct
);
168 static int pass_spill_struct_spill (int a
, int b
, int c
, int d
, int e
, TestStruct2 regStruct
)
171 retVal
= receive_struct_spill(a
,b
,c
,d
,e
,regStruct
);
175 static int pass_spill_struct_spill_big(int a
, int b
, int c
, int d
, int e
, TestStruct3 regStruct
)
178 retVal
= receive_struct_spill_big(a
,b
,c
,d
,e
,regStruct
);
182 static int test_0_spill ()
184 TestStruct3 myStruct
;
188 myStruct
= spill_struct(myStruct
);
189 if (myStruct
.c
== 99)
194 static int test_0_spill_void ()
196 TestStruct3 myStruct
;
200 return (spill_struct_void(myStruct
));
203 static int spill_struct_ret (TestStruct3 regStruct
)
205 return (regStruct
.c
);
209 static int test_0_spill_ret ()
211 TestStruct3 myStruct
;
215 if (spill_struct_ret(myStruct
) == 69)
220 static TestStruct2
struct_ret(TestStruct2 regStruct
)
227 static int test_0_struct_ret ()
229 TestStruct2 myStruct
;
232 myStruct
= struct_ret(myStruct
);
233 if (myStruct
.b
== 72)
239 static float TestSingle (float a
, float b
, float c
)
244 static int test_0_TestSingle ()
246 float a
= 3F
; float b
= 4.5F
; float c
= 900F
;
247 if (TestSingle(a
, b
, c
) == b
)
253 static int test_0_pass_spill ()
255 TestStruct2 myStruct
;
258 return (pass_spill_struct (1, 2, 3, 4, 5, myStruct
));
261 static int test_0_pass_spill_big ()
263 TestStruct3 myStruct
;
267 return (pass_spill_struct_big (1, 2, 3, 4, 5, myStruct
));
270 static int test_0_pass_struct_spill ()
272 TestStruct2 myStruct
;
275 return (pass_struct_spill (myStruct
));
278 static int test_0_pass_struct_spill_big ()
280 TestStruct3 myStruct
;
284 return (pass_struct_spill_big (myStruct
));
287 static int test_0_pass_spill_struct_spill ()
289 TestStruct2 myStruct
;
292 return (pass_spill_struct_spill (1,2,3,4,5,myStruct
));
295 static int test_0_pass_spill_struct_spill_big ()
297 TestStruct3 myStruct
;
301 return (pass_spill_struct_spill_big (1,2,3,4,5,myStruct
));
304 static long pass_long_odd (int a
, long b
)
309 static int test_0_pass_long_odd ()
313 if (pass_long_odd(a
,b
) == 9000)