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_1_bigmul1 () {
38 c = (long)a * (long)b;
44 static int test_1_bigmul2 () {
45 int a = System.Int32.MaxValue, b = System.Int32.MaxValue;
46 long s = System.Int64.MinValue;
48 c = s + (long) a * (long) b;
49 if (c == -4611686022722355199)
54 static int test_1_bigmul3 () {
57 c = (ulong) a * (ulong) b;
63 static int test_1_bigmul4 () {
64 int a = System.Int32.MaxValue, b = System.Int32.MaxValue;
66 c = (ulong) a * (ulong) b;
67 if (c == 4611686014132420609)
72 static int test_1_bigmul5 () {
73 int a = System.Int32.MaxValue, b = System.Int32.MinValue;
75 c = (long) a * (long) b;
76 if (c == -4611686016279904256)
81 static int test_1_bigmul6 () {
82 uint a = System.UInt32.MaxValue, b = System.UInt32.MaxValue/(uint)2;
84 c = (ulong) a * (ulong) b;
85 if (c == 9223372030412324865)
90 static int test_0_beq () {
91 long a = 0xffffffffff;
92 if (a != 0xffffffffff)
97 static int test_0_bne_un () {
98 long a = 0xffffffffff;
99 if (a == 0xfffffffffe)
104 static int test_0_ble () {
105 long a = 0xffffffffff;
106 if (a > 0xffffffffff)
111 static int test_0_ble_un () {
112 ulong a = 0xffffffffff;
113 if (a > 0xffffffffff)
118 static int test_0_bge () {
119 long a = 0xffffffffff;
120 if (a < 0xffffffffff)
125 static int test_0_bge_un () {
126 ulong a = 0xffffffffff;
127 if (a < 0xffffffffff)
132 static int test_0_blt () {
133 long a = 0xfffffffffe;
134 if (a >= 0xffffffffff)
139 static int test_0_blt_un () {
140 ulong a = 0xfffffffffe;
141 if (a >= 0xffffffffff)
146 static int test_0_bgt () {
147 long a = 0xffffffffff;
148 if (a <= 0xfffffffffe)
153 static int test_0_conv_to_i4 () {
158 static int test_0_conv_from_i4 () {
170 static int test_0_conv_from_i4_negative () {
183 static int test_0_conv_from_r8 () {
192 static int test_0_conv_from_r4 () {
202 static int test_8_and () {
203 long a = 0xffffffffff;
208 static int test_8_and_imm () {
209 long a = 0xffffffffff;
213 static int test_10_or () {
219 static int test_10_or_imm () {
224 static int test_5_xor () {
230 static int test_5_xor_imm () {
235 static int test_5_add () {
241 static int test_5_add_imm () {
246 static int test_0_add_imm_no_inc () {
247 // we can't blindly convert an add x, 1 to an inc x
248 long a = 0x1ffffffff;
251 if (c == ((a + 1) + 1))
256 static int test_5_sub () {
262 static int test_5_sub_imm () {
267 static int test_2_neg () {
272 static int test_0_shl () {
283 static int test_1_rshift ()
293 static int test_5_shift ()
323 static int test_1_simple_neg () {
331 static int test_2_compare () {
340 static int test_9_alu ()
385 static int test_24_mul () {
391 static int test_24_mul_ovf () {
402 static int test_24_mul_un () {
408 static int test_24_mul_ovf_un () {
419 static int test_4_divun () {
425 static int test_1431655764_bigdivun_imm () {
430 static int test_1431655764_bigdivun () {
436 static int test_1_remun () {
442 static int test_2_bigremun () {
448 static int test_0_ceq () {
452 long d = 0xff00000002;
454 bool val = (a == b); // this should produce a ceq
458 val = (a == c); // this should produce a ceq
462 val = (a == d); // this should produce a ceq
469 static int test_0_clt () {
473 long d = 0xff00000002L;
476 bool val = (a < b); // this should produce a clt
480 val = (a < c); // this should produce a clt
484 val = (c < a); // this should produce a clt
488 val = (e < d); // this should produce a clt
492 val = (d < e); // this should produce a clt
499 static int test_0_clt_un () {
503 ulong d = 0xff00000002;
504 ulong e = 0xffffffffffffffff;
506 bool val = (a < b); // this should produce a clt_un
510 val = (a < c); // this should produce a clt_un
514 val = (d < e); // this should produce a clt_un
518 val = (e < d); // this should produce a clt_un
525 static int test_0_cgt () {
529 long d = 0xff00000002L;
532 bool val = (a > b); // this should produce a cgt
536 val = (a > c); // this should produce a cgt
540 val = (c > a); // this should produce a cgt
544 val = (e > d); // this should produce a cgt
548 val = (d > e); // this should produce a cgt
555 static int test_0_cgt_un () {
559 ulong d = 0xff00000002;
560 ulong e = 0xffffffffffffffff;
562 bool val = (a > b); // this should produce a cgt_un
566 val = (a > c); // this should produce a cgt_un
570 val = (d > e); // this should produce a cgt_un
574 val = (e > d); // this should produce a cgt_un
581 static long return_5low () {
585 static long return_5high () {
589 static int test_3_long_ret () {
590 long val = return_5low ();
591 return (int) (val - 2);
594 static int test_1_long_ret2 () {
595 long val = return_5high ();
596 if (val > 0xffffffff)
601 static int test_3_byte_cast () {
602 ulong val = 0xff00ff00f0f0f0f0;
604 b = (byte) (val & 0xFF);
610 static int test_4_ushort_cast () {
611 ulong val = 0xff00ff00f0f0f0f0;
613 b = (ushort) (val & 0xFFFF);
619 static int test_500_mul_div () {
623 long res = val * exp / maxexp;
628 static long position = 0;
630 static int test_4_static_inc_long () {
638 return (int)position;
641 static void doit (double value, out long m) {
645 static int test_0_ftol_clobber () {
653 static int test_3_checked_cast_un () {
657 checked { j = (long)i; }
664 static int test_4_checked_cast () {
668 checked { j = (ulong)i; }