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_0_beq () {
73 long a = 0xffffffffff;
74 if (a != 0xffffffffff)
79 static int test_0_bne_un () {
80 long a = 0xffffffffff;
81 if (a == 0xfffffffffe)
86 static int test_0_ble () {
87 long a = 0xffffffffff;
93 static int test_0_ble_un () {
94 ulong a = 0xffffffffff;
100 static int test_0_bge () {
101 long a = 0xffffffffff;
102 if (a < 0xffffffffff)
107 static int test_0_bge_un () {
108 ulong a = 0xffffffffff;
109 if (a < 0xffffffffff)
114 static int test_0_blt () {
115 long a = 0xfffffffffe;
116 if (a >= 0xffffffffff)
121 static int test_0_blt_un () {
122 ulong a = 0xfffffffffe;
123 if (a >= 0xffffffffff)
128 static int test_0_bgt () {
129 long a = 0xffffffffff;
130 if (a <= 0xfffffffffe)
135 static int test_0_conv_to_i4 () {
140 static int test_0_conv_from_i4 () {
152 static int test_0_conv_from_i4_negative () {
165 static int test_0_conv_from_r8 () {
174 static int test_0_conv_from_r4 () {
184 static int test_8_and () {
185 long a = 0xffffffffff;
190 static int test_8_and_imm () {
191 long a = 0xffffffffff;
195 static int test_10_or () {
201 static int test_10_or_imm () {
206 static int test_5_xor () {
212 static int test_5_xor_imm () {
217 static int test_5_add () {
223 static int test_5_add_imm () {
228 static int test_0_add_imm_no_inc () {
229 // we can't blindly convert an add x, 1 to an inc x
230 long a = 0x1ffffffff;
233 if (c == ((a + 1) + 1))
238 static int test_5_sub () {
244 static int test_5_sub_imm () {
249 static int test_2_neg () {
254 static int test_0_shl () {
265 static int test_1_rshift ()
275 static int test_5_shift ()
305 static int test_1_simple_neg () {
313 static int test_2_compare () {
322 static int test_9_alu ()
367 static int test_24_mul () {
373 static int test_24_mul_ovf () {
384 static int test_24_mul_un () {
390 static int test_24_mul_ovf_un () {
401 static int test_4_divun () {
407 static int test_1431655764_bigdivun_imm () {
412 static int test_1431655764_bigdivun () {
418 static int test_1_remun () {
424 static int test_2_bigremun () {
430 static int test_0_ceq () {
434 long d = 0xff00000002;
436 bool val = (a == b); // this should produce a ceq
440 val = (a == c); // this should produce a ceq
444 val = (a == d); // this should produce a ceq
451 static int test_0_clt () {
455 long d = 0xff00000002L;
458 bool val = (a < b); // this should produce a clt
462 val = (a < c); // this should produce a clt
466 val = (c < a); // this should produce a clt
470 val = (e < d); // this should produce a clt
474 val = (d < e); // this should produce a clt
481 static int test_0_clt_un () {
485 ulong d = 0xff00000002;
486 ulong e = 0xffffffffffffffff;
488 bool val = (a < b); // this should produce a clt_un
492 val = (a < c); // this should produce a clt_un
496 val = (d < e); // this should produce a clt_un
500 val = (e < d); // this should produce a clt_un
507 static int test_0_cgt () {
511 long d = 0xff00000002L;
514 bool val = (a > b); // this should produce a cgt
518 val = (a > c); // this should produce a cgt
522 val = (c > a); // this should produce a cgt
526 val = (e > d); // this should produce a cgt
530 val = (d > e); // this should produce a cgt
537 static int test_0_cgt_un () {
541 ulong d = 0xff00000002;
542 ulong e = 0xffffffffffffffff;
544 bool val = (a > b); // this should produce a cgt_un
548 val = (a > c); // this should produce a cgt_un
552 val = (d > e); // this should produce a cgt_un
556 val = (e > d); // this should produce a cgt_un
563 static long return_5low () {
567 static long return_5high () {
571 static int test_3_long_ret () {
572 long val = return_5low ();
573 return (int) (val - 2);
576 static int test_1_long_ret2 () {
577 long val = return_5high ();
578 if (val > 0xffffffff)
583 static int test_3_byte_cast () {
584 ulong val = 0xff00ff00f0f0f0f0;
586 b = (byte) (val & 0xFF);
592 static int test_4_ushort_cast () {
593 ulong val = 0xff00ff00f0f0f0f0;
595 b = (ushort) (val & 0xFFFF);
601 static int test_500_mul_div () {
605 long res = val * exp / maxexp;
610 static long position = 0;
612 static int test_4_static_inc_long () {
620 return (int)position;
623 static void doit (double value, out long m) {
627 static int test_0_ftol_clobber () {
635 static int test_3_checked_cast_un () {
639 checked { j = (long)i; }
646 static int test_4_checked_cast () {
650 checked { j = (ulong)i; }