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_10_simple_cast () {
37 static int test_1_bigmul1 () {
43 c = (long)a * (long)b;
49 static int test_1_bigmul2 () {
50 int a = System.Int32.MaxValue, b = System.Int32.MaxValue;
51 long s = System.Int64.MinValue;
53 c = s + (long) a * (long) b;
54 if (c == -4611686022722355199)
59 static int test_1_bigmul3 () {
62 c = (ulong) a * (ulong) b;
68 static int test_1_bigmul4 () {
69 int a = System.Int32.MaxValue, b = System.Int32.MaxValue;
71 c = (ulong) a * (ulong) b;
72 if (c == 4611686014132420609)
77 static int test_1_bigmul5 () {
78 int a = System.Int32.MaxValue, b = System.Int32.MinValue;
80 c = (long) a * (long) b;
81 if (c == -4611686016279904256)
86 static int test_1_bigmul6 () {
87 uint a = System.UInt32.MaxValue, b = System.UInt32.MaxValue/(uint)2;
89 c = (ulong) a * (ulong) b;
90 if (c == 9223372030412324865)
95 static int test_0_beq () {
96 long a = 0xffffffffff;
97 if (a != 0xffffffffff)
102 static int test_0_bne_un () {
103 long a = 0xffffffffff;
104 if (a == 0xfffffffffe)
109 static int test_0_ble () {
110 long a = 0xffffffffff;
111 if (a > 0xffffffffff)
116 static int test_0_ble_un () {
117 ulong a = 0xffffffffff;
118 if (a > 0xffffffffff)
123 static int test_0_bge () {
124 long a = 0xffffffffff;
125 if (a < 0xffffffffff)
130 static int test_0_bge_un () {
131 ulong a = 0xffffffffff;
132 if (a < 0xffffffffff)
137 static int test_0_blt () {
138 long a = 0xfffffffffe;
139 if (a >= 0xffffffffff)
144 static int test_0_blt_un () {
145 ulong a = 0xfffffffffe;
146 if (a >= 0xffffffffff)
151 static int test_0_bgt () {
152 long a = 0xffffffffff;
153 if (a <= 0xfffffffffe)
158 static int test_0_conv_to_i4 () {
163 static int test_0_conv_from_i4 () {
175 static int test_0_conv_from_i4_negative () {
188 static int test_0_conv_from_r8 () {
197 static int test_0_conv_from_r4 () {
207 static int test_8_and () {
208 long a = 0xffffffffff;
213 static int test_8_and_imm () {
214 long a = 0xffffffffff;
218 static int test_10_or () {
224 static int test_10_or_imm () {
229 static int test_5_xor () {
235 static int test_5_xor_imm () {
240 static int test_5_add () {
246 static int test_5_add_imm () {
251 static int test_0_add_imm_no_inc () {
252 // we can't blindly convert an add x, 1 to an inc x
253 long a = 0x1ffffffff;
256 if (c == ((a + 1) + 1))
261 static int test_5_sub () {
267 static int test_5_sub_imm () {
272 static int test_2_neg () {
277 static int test_0_shl () {
288 static int test_1_rshift ()
298 static int test_5_shift ()
328 static int test_1_simple_neg () {
336 static int test_2_compare () {
345 static int test_9_alu ()
390 static int test_24_mul () {
396 static int test_24_mul_ovf () {
407 static int test_24_mul_un () {
413 static int test_24_mul_ovf_un () {
424 static int test_4_divun () {
430 static int test_1431655764_bigdivun_imm () {
435 static int test_1431655764_bigdivun () {
441 static int test_1_remun () {
447 static int test_2_bigremun () {
453 static int test_0_ceq () {
457 long d = 0xff00000002;
459 bool val = (a == b); // this should produce a ceq
463 val = (a == c); // this should produce a ceq
467 val = (a == d); // this should produce a ceq
474 static int test_0_clt () {
478 long d = 0xff00000002L;
481 bool val = (a < b); // this should produce a clt
485 val = (a < c); // this should produce a clt
489 val = (c < a); // this should produce a clt
493 val = (e < d); // this should produce a clt
497 val = (d < e); // this should produce a clt
504 static int test_0_clt_un () {
508 ulong d = 0xff00000002;
509 ulong e = 0xffffffffffffffff;
511 bool val = (a < b); // this should produce a clt_un
515 val = (a < c); // this should produce a clt_un
519 val = (d < e); // this should produce a clt_un
523 val = (e < d); // this should produce a clt_un
530 static int test_0_cgt () {
534 long d = 0xff00000002L;
537 bool val = (a > b); // this should produce a cgt
541 val = (a > c); // this should produce a cgt
545 val = (c > a); // this should produce a cgt
549 val = (e > d); // this should produce a cgt
553 val = (d > e); // this should produce a cgt
560 static int test_0_cgt_un () {
564 ulong d = 0xff00000002;
565 ulong e = 0xffffffffffffffff;
567 bool val = (a > b); // this should produce a cgt_un
571 val = (a > c); // this should produce a cgt_un
575 val = (d > e); // this should produce a cgt_un
579 val = (e > d); // this should produce a cgt_un
586 static long return_5low () {
590 static long return_5high () {
594 static int test_3_long_ret () {
595 long val = return_5low ();
596 return (int) (val - 2);
599 static int test_1_long_ret2 () {
600 long val = return_5high ();
601 if (val > 0xffffffff)
606 static int test_3_byte_cast () {
607 ulong val = 0xff00ff00f0f0f0f0;
609 b = (byte) (val & 0xFF);
615 static int test_4_ushort_cast () {
616 ulong val = 0xff00ff00f0f0f0f0;
618 b = (ushort) (val & 0xFFFF);
624 static int test_500_mul_div () {
628 long res = val * exp / maxexp;
633 static long position = 0;
635 static int test_4_static_inc_long () {
643 return (int)position;
646 static void doit (double value, out long m) {
650 static int test_0_ftol_clobber () {
658 static int test_3_checked_cast_un () {
662 checked { j = (long)i; }
669 static int test_4_checked_cast () {
673 checked { j = (ulong)i; }