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_2_sub_large_imm () {
108 static int test_0_sub_inv_imm () {
113 static int test_2_and () {
119 static int test_0_and_imm () {
124 static int test_0_and_large_imm () {
126 return b & 0x10000000;
129 static int test_0_and_large_imm2 () {
131 return b & 0x100000f0;
134 static int test_2_div () {
140 static int test_4_div_imm () {
145 static int test_4_divun_imm () {
150 static int test_0_div_fold () {
155 static int test_719177_div_destreg () {
157 return ((365* (year-1)) + ((year-1)/4));
160 static int test_1_remun_imm () {
165 static int test_2_bigremun_imm () {
172 static int test_2_rem () {
178 static int test_4_rem_imm () {
183 static int test_4_rem_big_imm () {
188 static int test_9_mul () {
194 static int test_15_mul_imm () {
199 static int test_24_mul () {
209 static int test_24_mul_ovf () {
221 static int test_24_mul_un () {
231 static int test_24_mul_ovf_un () {
243 static int test_3_or () {
249 static int test_3_or_un () {
255 static int test_3_or_short_un () {
261 static int test_18_or_imm () {
266 static int test_268435458_or_large_imm () {
268 return b | 0x10000000;
271 static int test_268435459_or_large_imm2 () {
273 return b | 0x10000001;
276 static int test_1_xor () {
282 static int test_1_xor_imm () {
287 static int test_983041_xor_imm_large () {
292 static int test_1_neg () {
298 static int test_2_not () {
304 static int test_16_shift () {
310 static int test_16_shift_add () {
317 static int test_16_shift_add2 () {
324 static int test_16_shift_imm () {
329 static int test_524288_shift_imm_large () {
334 static int test_12_shift_imm_inv () {
339 static int test_12_shift_imm_inv_sbyte () {
344 static int test_1_rshift_imm () {
349 static int test_2_unrshift_imm () {
351 return (int)(b >> 3);
354 static int test_0_bigunrshift_imm () {
364 static int test_0_bigrshift_imm () {
372 static int test_1_rshift () {
378 static int test_2_unrshift () {
381 return (int)(b >> a);
384 static int test_0_bigunrshift () {
395 static int test_0_bigrshift () {
404 static int test_2_cond () {
411 static int test_2_cond_short () {
412 short b = 2, a = 3, c;
418 static int test_2_cond_sbyte () {
419 sbyte b = 2, a = 3, c;
425 static int test_6_cascade_cond () {
439 static int test_6_cascade_short () {
440 short b = 2, a = 3, c;
453 static int test_0_short_sign_extend () {
455 short s1 = (short)t1;
458 if ((uint)t2 != 0xffffeedd)
464 static int test_15_for_loop () {
466 for (i = 0; i < 15; ++i) {
471 static int test_11_nested_for_loop () {
472 int i, j = 0; /* mcs bug here if j not set */
473 for (i = 0; i < 15; ++i) {
474 for (j = 200; j >= 5; --j) ;
479 static int test_11_several_nested_for_loops () {
480 int i, j = 0; /* mcs bug here if j not set */
481 for (i = 0; i < 15; ++i) {
482 for (j = 200; j >= 5; --j) ;
485 for (i = 0; i < 15; ++i) {
486 for (j = 200; j >= 5; --j) ;
491 static int test_0_conv_ovf_i1 () {
494 //for (int j = 0; j < 10000000; j++)
505 static int test_0_conv_ovf_i1_un () {
516 static int test_0_conv_ovf_i2 () {
529 static int test_0_conv_ovf_i2_un () {
540 static int test_0_conv_ovf_u2 () {
545 UInt16 b = (UInt16)c;
551 static int test_0_conv_ovf_u2_un () {
556 UInt16 b = (UInt16)c;
562 static int test_0_conv_ovf_u4 () {
573 static int test_0_bool () {
580 static int test_1_bool_inverted () {
587 static int test_1_bool_assign () {
589 val = !val; // this should produce a ceq
595 static int test_1_bool_multi () {
599 if ((val && !val2) && (!val2 && val))
604 static int test_16_spill () {
611 return (1 + (a + (b + (c + (d + e)))));
614 static int test_1_switch () {
628 static int test_0_while_loop_1 () {
634 } while (value != 0);
639 static int test_0_while_loop_2 () {
645 } while (value != 0 && position > 1);
650 static int test_0_char_conv () {
653 char tc = (char) ('0' + i);
661 static int test_3_shift_regalloc () {
666 orig &= ~(0xff << shift);
667 orig |= value << shift;
676 static int test_2_optimize_branches () {
686 static int test_0_checked_byte_cast () {
688 int b = checked ((byte) (v));
695 static int test_0_checked_byte_cast_un () {
697 uint b = checked ((byte) (v));
704 static int test_0_checked_short_cast () {
706 int b = checked ((ushort) (v));
713 static int test_0_checked_short_cast_un () {
715 uint b = checked ((ushort) (v));
722 static int test_1_a_eq_b_plus_a () {
728 static int test_0_comp_unsigned () {
787 static int test_16_cmov ()