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 static int test_0_return () {
36 static int test_100000_return_large () {
40 static int test_1_load_bool () {
45 static int test_0_load_bool_false () {
50 static int test_200_load_byte () {
55 static int test_100_load_sbyte () {
60 static int test_200_load_short () {
65 static int test_100_load_ushort () {
70 static int test_3_add_simple () {
76 static int test_3_add_imm () {
81 static int test_13407573_add_largeimm () {
86 static int test_1_sub_simple () {
92 static int test_1_sub_simple_un () {
98 static int test_1_sub_imm () {
103 static int test_0_sub_inv_imm () {
108 static int test_2_and () {
114 static int test_0_and_imm () {
119 static int test_0_and_large_imm () {
121 return b & 0x10000000;
124 static int test_2_div () {
130 static int test_4_div_imm () {
135 static int test_4_divun_imm () {
140 static int test_0_div_fold () {
145 static int test_1_remun_imm () {
150 static int test_2_bigremun_imm () {
155 static int test_2_rem () {
161 static int test_4_rem_imm () {
166 static int test_9_mul () {
172 static int test_15_mul_imm () {
177 static int test_24_mul () {
187 static int test_24_mul_ovf () {
199 static int test_24_mul_un () {
209 static int test_24_mul_ovf_un () {
221 static int test_3_or () {
227 static int test_3_or_un () {
233 static int test_3_or_short_un () {
239 static int test_18_or_imm () {
244 static int test_268435458_or_large_imm () {
246 return b | 0x10000000;
249 static int test_1_neg () {
255 static int test_2_not () {
261 static int test_16_shift () {
267 static int test_16_shift_add () {
274 static int test_16_shift_add2 () {
281 static int test_16_shift_imm () {
286 static int test_12_shift_imm_inv () {
291 static int test_12_shift_imm_inv_sbyte () {
296 static int test_1_rshift_imm () {
301 static int test_2_unrshift_imm () {
303 return (int)(b >> 3);
306 static int test_0_bigunrshift_imm () {
314 static int test_0_bigrshift_imm () {
322 static int test_1_rshift () {
328 static int test_2_unrshift () {
331 return (int)(b >> a);
334 static int test_0_bigunrshift () {
343 static int test_0_bigrshift () {
352 static int test_2_cond () {
359 static int test_2_cond_short () {
360 short b = 2, a = 3, c;
366 static int test_2_cond_sbyte () {
367 sbyte b = 2, a = 3, c;
373 static int test_6_cascade_cond () {
387 static int test_6_cascade_short () {
388 short b = 2, a = 3, c;
401 static int test_15_for_loop () {
403 for (i = 0; i < 15; ++i) {
408 static int test_11_nested_for_loop () {
409 int i, j = 0; /* mcs bug here if j not set */
410 for (i = 0; i < 15; ++i) {
411 for (j = 200; j >= 5; --j) ;
416 static int test_11_several_nested_for_loops () {
417 int i, j = 0; /* mcs bug here if j not set */
418 for (i = 0; i < 15; ++i) {
419 for (j = 200; j >= 5; --j) ;
422 for (i = 0; i < 15; ++i) {
423 for (j = 200; j >= 5; --j) ;
428 static int test_0_conv_ovf_i1 () {
431 //for (int j = 0; j < 10000000; j++)
442 static int test_0_conv_ovf_i1_un () {
453 static int test_0_conv_ovf_i2 () {
466 static int test_0_conv_ovf_i2_un () {
477 static int test_0_conv_ovf_u2 () {
482 UInt16 b = (UInt16)c;
488 static int test_0_conv_ovf_u2_un () {
493 UInt16 b = (UInt16)c;
499 static int test_0_conv_ovf_u4 () {
510 static int test_0_bool () {
517 static int test_1_bool_inverted () {
524 static int test_1_bool_assign () {
526 val = !val; // this should produce a ceq
532 static int test_1_bool_multi () {
536 if ((val && !val2) && (!val2 && val))
541 static int test_16_spill () {
548 return (1 + (a + (b + (c + (d + e)))));
551 static int test_1_switch () {
565 static int test_0_while_loop_1 () {
571 } while (value != 0);
576 static int test_0_while_loop_2 () {
582 } while (value != 0 && position > 1);
587 static int test_0_char_conv () {
590 char tc = (char) ('0' + i);
598 static int test_3_shift_regalloc () {
603 orig &= ~(0xff << shift);
604 orig |= value << shift;
613 static int test_2_optimize_branches () {
623 static int test_0_checked_byte_cast () {
625 int b = checked ((byte) (v));
632 static int test_0_checked_byte_cast_un () {
634 uint b = checked ((byte) (v));
641 static int test_0_checked_short_cast () {
643 int b = checked ((ushort) (v));
650 static int test_0_checked_short_cast_un () {
652 uint b = checked ((ushort) (v));