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_0_return () {
36 public static int test_100000_return_large () {
40 public static int test_1_load_bool () {
45 public static int test_0_load_bool_false () {
50 public static int test_200_load_byte () {
55 public static int test_100_load_sbyte () {
60 public static int test_200_load_short () {
65 public static int test_100_load_ushort () {
70 public static int test_3_add_simple () {
76 public static int test_3_add_imm () {
81 public static int test_13407573_add_largeimm () {
86 public static int test_1_sub_simple () {
92 public static int test_1_sub_simple_un () {
98 public static int test_1_sub_imm () {
103 public static int test_2_sub_large_imm () {
108 public static int test_0_sub_inv_imm () {
113 public static int test_2_and () {
119 public static int test_0_and_imm () {
124 public static int test_0_and_large_imm () {
126 return b & 0x10000000;
129 public static int test_0_and_large_imm2 () {
131 return b & 0x100000f0;
134 public static int test_2_div () {
140 public static int test_4_div_imm () {
145 public static int test_4_divun_imm () {
150 public static int test_0_div_fold () {
155 public static int test_719177_div_destreg () {
157 return ((365* (year-1)) + ((year-1)/4));
160 public static int test_1_remun_imm () {
165 public static int test_2_bigremun_imm () {
172 public static int test_2_rem () {
178 public static int test_4_rem_imm () {
183 public static int test_4_rem_big_imm () {
188 public static int test_9_mul () {
194 public static int test_15_mul_imm () {
199 public static int test_24_mul () {
209 public static int test_24_mul_ovf () {
221 public static int test_24_mul_un () {
231 public static int test_24_mul_ovf_un () {
243 public static int test_0_add_ovf () {
247 i = System.Int32.MinValue;
252 if (k != System.Int32.MinValue)
256 i = System.Int32.MaxValue;
261 if (k != System.Int32.MaxValue)
265 i = System.Int32.MinValue;
266 j = System.Int32.MaxValue;
274 i = System.Int32.MaxValue;
275 j = System.Int32.MinValue;
283 i = System.Int32.MinValue + 1234;
288 if (k != System.Int32.MinValue)
292 i = System.Int32.MaxValue - 1234;
297 if (k != System.Int32.MaxValue)
303 public static int test_0_add_un_ovf () {
304 uint n = (uint)134217728 * 16;
305 uint number = checked (n + (uint)0);
307 return number == n ? 0 : 1;
310 public static int test_3_or () {
316 public static int test_3_or_un () {
322 public static int test_3_or_short_un () {
328 public static int test_18_or_imm () {
333 public static int test_268435458_or_large_imm () {
335 return b | 0x10000000;
338 public static int test_268435459_or_large_imm2 () {
340 return b | 0x10000001;
343 public static int test_1_xor () {
349 public static int test_1_xor_imm () {
354 public static int test_983041_xor_imm_large () {
359 public static int test_1_neg () {
365 public static int test_2_not () {
371 public static int test_16_shift () {
377 public static int test_16_shift_add () {
384 public static int test_16_shift_add2 () {
391 public static int test_16_shift_imm () {
396 public static int test_524288_shift_imm_large () {
401 public static int test_12_shift_imm_inv () {
406 public static int test_12_shift_imm_inv_sbyte () {
411 public static int test_1_rshift_imm () {
416 public static int test_2_unrshift_imm () {
418 return (int)(b >> 3);
421 public static int test_0_bigunrshift_imm () {
431 public static int test_0_bigrshift_imm () {
439 public static int test_1_rshift () {
445 public static int test_2_unrshift () {
448 return (int)(b >> a);
451 public static int test_0_bigunrshift () {
462 public static int test_0_bigrshift () {
471 public static int test_2_cond () {
478 public static int test_2_cond_short () {
479 short b = 2, a = 3, c;
485 public static int test_2_cond_sbyte () {
486 sbyte b = 2, a = 3, c;
492 public static int test_6_cascade_cond () {
506 public static int test_6_cascade_short () {
507 short b = 2, a = 3, c;
520 public static int test_0_short_sign_extend () {
522 short s1 = (short)t1;
525 if ((uint)t2 != 0xffffeedd)
531 public static int test_15_for_loop () {
533 for (i = 0; i < 15; ++i) {
538 public static int test_11_nested_for_loop () {
539 int i, j = 0; /* mcs bug here if j not set */
540 for (i = 0; i < 15; ++i) {
541 for (j = 200; j >= 5; --j) ;
546 public static int test_11_several_nested_for_loops () {
547 int i, j = 0; /* mcs bug here if j not set */
548 for (i = 0; i < 15; ++i) {
549 for (j = 200; j >= 5; --j) ;
552 for (i = 0; i < 15; ++i) {
553 for (j = 200; j >= 5; --j) ;
558 public static int test_0_conv_ovf_i1 () {
561 //for (int j = 0; j < 10000000; j++)
572 public static int test_0_conv_ovf_i1_un () {
583 public static int test_0_conv_ovf_i2 () {
601 public static int test_0_conv_ovf_i2_un () {
612 public static int test_0_conv_ovf_u2 () {
617 UInt16 b = (UInt16)c;
623 public static int test_0_conv_ovf_u2_un () {
628 UInt16 b = (UInt16)c;
634 public static int test_0_conv_ovf_u4 () {
645 public static int test_0_bool () {
652 public static int test_1_bool_inverted () {
659 public static int test_1_bool_assign () {
661 val = !val; // this should produce a ceq
667 public static int test_1_bool_multi () {
671 if ((val && !val2) && (!val2 && val))
676 public static int test_16_spill () {
683 return (1 + (a + (b + (c + (d + e)))));
686 public static int test_1_switch () {
699 public static int test_0_switch_constprop () {
712 public static int test_0_switch_constprop2 () {
725 public static int test_0_while_loop_1 () {
731 } while (value != 0);
736 public static int test_0_while_loop_2 () {
742 } while (value != 0 && position > 1);
747 public static int test_0_char_conv () {
750 char tc = (char) ('0' + i);
758 public static int test_3_shift_regalloc () {
763 orig &= ~(0xff << shift);
764 orig |= value << shift;
773 public static int test_2_optimize_branches () {
783 public static int test_0_checked_byte_cast () {
785 int b = checked ((byte) (v));
792 public static int test_0_checked_byte_cast_un () {
794 uint b = checked ((byte) (v));
801 public static int test_0_checked_short_cast () {
803 int b = checked ((ushort) (v));
810 public static int test_0_checked_short_cast_un () {
812 uint b = checked ((ushort) (v));
819 public static int test_1_a_eq_b_plus_a () {
825 public static int test_0_comp () {
854 public static int test_0_comp_unsigned () {
913 public static int test_16_cmov ()
922 public static int test_0_and_cmp ()
925 int local = 0x01020304;
927 if ((local & 0x01020304) == 0)
930 if ((local & 0x00000304) == 0)
933 if ((local & 0x00000004) == 0)
936 if ((local & 0x00000300) == 0)
939 if ((local & 0x00020000) == 0)
942 if ((local & 0x01000000) == 0)
948 public static int test_0_cne ()
965 public static int test_0_byte_compares ()
971 if (!(b < System.Byte.MaxValue))
974 if (!(b <= System.Byte.MaxValue))
979 public static int test_0_cmp_regvar_zero ()
983 if (!(n > 0 && n >= 0 && n != 0))
985 if (n < 0 || n <= 0 || n == 0)