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_0_add_un_ovf () {
244 uint n = (uint)134217728 * 16;
245 uint number = checked (n + (uint)0);
247 return number == n ? 0 : 1;
250 static int test_3_or () {
256 static int test_3_or_un () {
262 static int test_3_or_short_un () {
268 static int test_18_or_imm () {
273 static int test_268435458_or_large_imm () {
275 return b | 0x10000000;
278 static int test_268435459_or_large_imm2 () {
280 return b | 0x10000001;
283 static int test_1_xor () {
289 static int test_1_xor_imm () {
294 static int test_983041_xor_imm_large () {
299 static int test_1_neg () {
305 static int test_2_not () {
311 static int test_16_shift () {
317 static int test_16_shift_add () {
324 static int test_16_shift_add2 () {
331 static int test_16_shift_imm () {
336 static int test_524288_shift_imm_large () {
341 static int test_12_shift_imm_inv () {
346 static int test_12_shift_imm_inv_sbyte () {
351 static int test_1_rshift_imm () {
356 static int test_2_unrshift_imm () {
358 return (int)(b >> 3);
361 static int test_0_bigunrshift_imm () {
371 static int test_0_bigrshift_imm () {
379 static int test_1_rshift () {
385 static int test_2_unrshift () {
388 return (int)(b >> a);
391 static int test_0_bigunrshift () {
402 static int test_0_bigrshift () {
411 static int test_2_cond () {
418 static int test_2_cond_short () {
419 short b = 2, a = 3, c;
425 static int test_2_cond_sbyte () {
426 sbyte b = 2, a = 3, c;
432 static int test_6_cascade_cond () {
446 static int test_6_cascade_short () {
447 short b = 2, a = 3, c;
460 static int test_0_short_sign_extend () {
462 short s1 = (short)t1;
465 if ((uint)t2 != 0xffffeedd)
471 static int test_15_for_loop () {
473 for (i = 0; i < 15; ++i) {
478 static int test_11_nested_for_loop () {
479 int i, j = 0; /* mcs bug here if j not set */
480 for (i = 0; i < 15; ++i) {
481 for (j = 200; j >= 5; --j) ;
486 static int test_11_several_nested_for_loops () {
487 int i, j = 0; /* mcs bug here if j not set */
488 for (i = 0; i < 15; ++i) {
489 for (j = 200; j >= 5; --j) ;
492 for (i = 0; i < 15; ++i) {
493 for (j = 200; j >= 5; --j) ;
498 static int test_0_conv_ovf_i1 () {
501 //for (int j = 0; j < 10000000; j++)
512 static int test_0_conv_ovf_i1_un () {
523 static int test_0_conv_ovf_i2 () {
541 static int test_0_conv_ovf_i2_un () {
552 static int test_0_conv_ovf_u2 () {
557 UInt16 b = (UInt16)c;
563 static int test_0_conv_ovf_u2_un () {
568 UInt16 b = (UInt16)c;
574 static int test_0_conv_ovf_u4 () {
585 static int test_0_bool () {
592 static int test_1_bool_inverted () {
599 static int test_1_bool_assign () {
601 val = !val; // this should produce a ceq
607 static int test_1_bool_multi () {
611 if ((val && !val2) && (!val2 && val))
616 static int test_16_spill () {
623 return (1 + (a + (b + (c + (d + e)))));
626 static int test_1_switch () {
640 static int test_0_while_loop_1 () {
646 } while (value != 0);
651 static int test_0_while_loop_2 () {
657 } while (value != 0 && position > 1);
662 static int test_0_char_conv () {
665 char tc = (char) ('0' + i);
673 static unsafe int test_0_pin_string () {
675 fixed (char *c = x) {
682 static int test_3_shift_regalloc () {
687 orig &= ~(0xff << shift);
688 orig |= value << shift;
697 static int test_2_optimize_branches () {
707 static int test_0_checked_byte_cast () {
709 int b = checked ((byte) (v));
716 static int test_0_checked_byte_cast_un () {
718 uint b = checked ((byte) (v));
725 static int test_0_checked_short_cast () {
727 int b = checked ((ushort) (v));
734 static int test_0_checked_short_cast_un () {
736 uint b = checked ((ushort) (v));
743 static int test_1_a_eq_b_plus_a () {
749 static int test_0_comp () {
778 static int test_0_comp_unsigned () {
837 static int test_16_cmov ()
847 static int test_0_and_cmp ()
850 /* various forms of test [mem], imm */
852 my_flags = 0x01020304;
854 if ((my_flags & 0x01020304) == 0)
857 if ((my_flags & 0x00000304) == 0)
860 if ((my_flags & 0x00000004) == 0)
863 if ((my_flags & 0x00000300) == 0)
866 if ((my_flags & 0x00020000) == 0)
869 if ((my_flags & 0x01000000) == 0)
873 int local = 0x01020304;
875 if ((local & 0x01020304) == 0)
878 if ((local & 0x00000304) == 0)
881 if ((local & 0x00000004) == 0)
884 if ((local & 0x00000300) == 0)
887 if ((local & 0x00020000) == 0)
890 if ((local & 0x01000000) == 0)
896 static int test_0_cne ()
913 static int test_0_byte_compares ()
919 if (!(b < System.Byte.MaxValue))
922 if (!(b <= System.Byte.MaxValue))
927 static int test_0_cmp_regvar_zero ()
931 if (!(n > 0 && n >= 0 && n != 0))
933 if (n < 0 || n <= 0 || n == 0)