2 using System.Reflection;
5 * Regression tests for the mono JIT.
7 * Each test needs to be of the form:
9 * public 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
26 /* A comparison made to same variable. */
27 #pragma warning disable 1718
37 public static int Main (string[] args) {
38 return TestDriver.RunTests (typeof (Tests), args);
42 public static int test_0_beq () {
49 public static int test_0_bne_un () {
56 public static int test_0_conv_r8 () {
63 public static int test_0_conv_i () {
74 ushort us = (ushort)a;
83 /* MS.NET special cases these */
84 double d = Double.NaN;
88 d = Double.PositiveInfinity;
92 d = Double.NegativeInfinity;
96 /* FIXME: This fails with llvm and with gcc -O2 on osx/linux */
100 if (i != -2147483648)
107 public static int test_5_conv_r4 () {
113 public static int test_0_conv_r4_m1 () {
119 public static int test_5_double_conv_r4 () {
125 public static int test_5_float_conv_r8 () {
127 double d = (double)f;
131 public static int test_5_conv_r8 () {
133 double f = (double)i;
137 public static int test_5_add () {
143 public static int test_5_sub () {
149 public static int test_24_mul () {
155 public static int test_4_div () {
161 public static int test_2_rem () {
167 public static int test_2_neg () {
172 public static int test_46_float_add_spill () {
173 // we overflow the FP stack
184 return (int)(1.0 + (a + (b + (c + (d + (e + (f + (g + (h + i)))))))));
187 public static int test_4_float_sub_spill () {
188 // we overflow the FP stack
199 return -(int)(1.0 - (a - (b - (c - (d - (e - (f - (g - (h - i)))))))));
200 ////// -(int)(1.0 - (1 - (2 - (3 - (4 - (5 - (6 - (7 - (8 - 9)))))))));
203 public static int test_362880_float_mul_spill () {
204 // we overflow the FP stack
215 return (int)(1.0 * (a * (b * (c * (d * (e * (f * (g * (h * i)))))))));
218 public static int test_4_long_cast () {
220 double d = (double)a;
232 public static int test_4_ulong_cast () {
234 double d = (double)a;
238 a = 0xffffffffffffffff;
245 public static int test_4_single_long_cast () {
259 public static int test_0_lconv_to_r8 () {
261 double b = (double) a;
268 public static int test_0_lconv_to_r4 () {
277 static void doit (double value, out long m) {
281 public static int test_0_ftol_clobber () {
289 public static int test_0_rounding () {
290 long ticks = 631502475130080000L;
291 long ticksperday = 864000000000L;
293 double days = (double) ticks / ticksperday;
295 if ((int)days != 730905)
301 /* FIXME: This only works on little-endian machines */
303 static unsafe int test_2_negative_zero () {
308 byte *ptr = (byte*)&d;
322 public static int test_16_float_cmp () {
411 public static int test_15_float_cmp_un () {
412 double a = Double.NaN;
495 public static int test_15_float_branch () {
563 public static int test_15_float_branch_un () {
564 double a = Double.NaN;
631 public static int test_0_float_precision () {
632 float f1 = 3.40282346638528859E+38f;
633 float f2 = 3.40282346638528859E+38f;
634 float PositiveInfinity = 1.0f / 0.0f;
637 return f == PositiveInfinity ? 0 : 1;
640 static double VALUE = 0.19975845134874831D;
642 public static int test_0_float_conversion_reduces_double_precision () {
643 double d = (float)VALUE;
644 if (d != 0.19975845515727997d)
650 /* This doesn't work with llvm */
652 public static int test_0_long_to_double_conversion ()
654 long l = 9223372036854775807L;
655 long conv = (long)((double)l);
656 if (conv != -9223372036854775808L)
663 public static int INT_VAL = 0x13456799;
665 public static int test_0_int4_to_float_convertion ()
667 double d = (double)(float)INT_VAL;
674 public static int test_0_int8_to_float_convertion ()
676 double d = (double)(float)(long)INT_VAL;
683 public static int test_5_r4_fadd () {
686 return (int)(f1 + f2);
689 public static int test_1_r4_fsub () {
692 return (int)(f1 - f2);
695 public static int test_6_fmul_r4 () {
698 return (int)(f1 * f2);
701 public static int test_3_fdiv_r4 () {
704 return (int)(f1 / f2);
707 public static int test_1_frem_r4 () {
710 return (int)(f1 % f2);
713 public static int test_0_fcmp_eq_r4 () {
716 return f1 == f2 ? 0 : 1;
719 public static int test_0_fcmp_eq_2_r4 () {
722 return f1 == f2 ? 1 : 0;
725 public static int test_0_fcmp_eq_r4_mixed () {
728 return f1 == f2 ? 0 : 1;
731 public static int test_3_iconv_to_r4 () {
737 public static int test_2_neg_r4 () {
742 public static int test_0_fceq_r4 () {
749 public static int test_0_fcgt_r4 () {
754 return res && !res2 ? 0 : 1;
757 public static int test_0_fclt_r4 () {
762 return res && !res2 ? 0 : 1;
765 public static int test_0_fclt_un_r4 () {
769 bool res2 = f2 >= f1;
770 return res && !res2 ? 0 : 1;
773 public static int test_0_fcgt_un_r4 () {
777 bool res2 = f2 <= f1;
778 return res && !res2 ? 0 : 1;
781 public static int test_0_fconv_to_u4_r4 () {
785 return b == 10 ? 0 : 1;
788 public static int test_0_fconv_to_u1_r4 () {
792 return b == 10 ? 0 : 1;
795 public static int test_0_fconv_to_i1_r4 () {
799 return b == 127 ? 0 : 1;
802 public static int test_0_fconv_to_u2_r4 () {
805 ushort b = (ushort)a;
806 return b == 10 ? 0 : 1;
809 public static int test_0_fconv_to_i2_r4 () {
813 return b == 127 ? 0 : 1;
816 public static int test_10_rconv_to_u8 () {