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_beq () {
33 long a = 0xffffffffff;
34 if (a != 0xffffffffff)
39 static int test_0_bne_un () {
40 long a = 0xffffffffff;
41 if (a == 0xfffffffffe)
46 static int test_0_ble () {
47 long a = 0xffffffffff;
53 static int test_0_ble_un () {
54 ulong a = 0xffffffffff;
60 static int test_0_bge () {
61 long a = 0xffffffffff;
67 static int test_0_bge_un () {
68 ulong a = 0xffffffffff;
74 static int test_0_blt () {
75 long a = 0xfffffffffe;
76 if (a >= 0xffffffffff)
81 static int test_0_blt_un () {
82 ulong a = 0xfffffffffe;
83 if (a >= 0xffffffffff)
88 static int test_0_bgt () {
89 long a = 0xffffffffff;
90 if (a <= 0xfffffffffe)
95 static int test_0_conv_to_i4 () {
100 static int test_0_conv_from_i4 () {
112 static int test_0_conv_from_i4_negative () {
125 static int test_0_conv_from_r8 () {
134 static int test_0_conv_from_r4 () {
144 static int test_8_and () {
145 long a = 0xffffffffff;
150 static int test_8_and_imm () {
151 long a = 0xffffffffff;
155 static int test_10_or () {
161 static int test_10_or_imm () {
166 static int test_5_xor () {
172 static int test_5_xor_imm () {
177 static int test_5_add () {
183 static int test_5_add_imm () {
188 static int test_0_add_imm_no_inc () {
189 // we can't blindly convert an add x, 1 to an inc x
190 long a = 0x1ffffffff;
193 if (c == ((a + 1) + 1))
198 static int test_5_sub () {
204 static int test_5_sub_imm () {
209 static int test_2_neg () {
214 static int test_0_shl () {
225 static int test_1_rshift ()
235 static int test_5_shift ()
265 static int test_1_simple_neg () {
273 static int test_2_compare () {
282 static int test_9_alu ()
327 static int test_24_mul () {
333 static int test_24_mul_ovf () {
344 static int test_24_mul_un () {
350 static int test_24_mul_ovf_un () {
361 static int test_4_divun () {
367 static int test_1431655764_bigdivun_imm () {
372 static int test_1431655764_bigdivun () {
378 static int test_1_remun () {
384 static int test_2_bigremun () {
390 static int test_0_ceq () {
394 long d = 0xff00000002;
396 bool val = (a == b); // this should produce a ceq
400 val = (a == c); // this should produce a ceq
404 val = (a == d); // this should produce a ceq
411 static int test_0_clt () {
415 long d = 0xff00000002L;
418 bool val = (a < b); // this should produce a clt
422 val = (a < c); // this should produce a clt
426 val = (c < a); // this should produce a clt
430 val = (e < d); // this should produce a clt
434 val = (d < e); // this should produce a clt
441 static int test_0_clt_un () {
445 ulong d = 0xff00000002;
446 ulong e = 0xffffffffffffffff;
448 bool val = (a < b); // this should produce a clt_un
452 val = (a < c); // this should produce a clt_un
456 val = (d < e); // this should produce a clt_un
460 val = (e < d); // this should produce a clt_un
467 static int test_0_cgt () {
471 long d = 0xff00000002L;
474 bool val = (a > b); // this should produce a cgt
478 val = (a > c); // this should produce a cgt
482 val = (c > a); // this should produce a cgt
486 val = (e > d); // this should produce a cgt
490 val = (d > e); // this should produce a cgt
497 static int test_0_cgt_un () {
501 ulong d = 0xff00000002;
502 ulong e = 0xffffffffffffffff;
504 bool val = (a > b); // this should produce a cgt_un
508 val = (a > c); // this should produce a cgt_un
512 val = (d > e); // this should produce a cgt_un
516 val = (e > d); // this should produce a cgt_un
523 static long return_5low () {
527 static long return_5high () {
531 static int test_3_long_ret () {
532 long val = return_5low ();
533 return (int) (val - 2);
536 static int test_1_long_ret2 () {
537 long val = return_5high ();
538 if (val > 0xffffffff)
543 static int test_3_byte_cast () {
544 ulong val = 0xff00ff00f0f0f0f0;
546 b = (byte) (val & 0xFF);
552 static int test_4_ushort_cast () {
553 ulong val = 0xff00ff00f0f0f0f0;
555 b = (ushort) (val & 0xFFFF);
561 static int test_500_mul_div () {
565 long res = val * exp / maxexp;
570 static long position = 0;
572 static int test_4_static_inc_long () {
580 return (int)position;
583 static void doit (double value, out long m) {
587 static int test_0_ftol_clobber () {