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
31 public static int Main () {
32 return TestDriver.RunTests (typeof (Tests));
35 public static int test_0_beq () {
42 public static int test_0_bne_un () {
49 public static int test_0_conv_r8 () {
56 public static int test_0_conv_i () {
67 ushort us = (ushort)a;
79 public static int test_5_conv_r4 () {
85 public static int test_0_conv_r4_m1 () {
91 public static int test_5_double_conv_r4 () {
97 public static int test_5_float_conv_r8 () {
103 public static int test_5_conv_r8 () {
105 double f = (double)i;
109 public static int test_5_add () {
115 public static int test_5_sub () {
121 public static int test_24_mul () {
127 public static int test_4_div () {
133 public static int test_2_rem () {
139 public static int test_2_neg () {
144 public static int test_46_float_add_spill () {
145 // we overflow the FP stack
156 return (int)(1.0 + (a + (b + (c + (d + (e + (f + (g + (h + i)))))))));
159 public static int test_4_float_sub_spill () {
160 // we overflow the FP stack
171 return -(int)(1.0 - (a - (b - (c - (d - (e - (f - (g - (h - i)))))))));
172 ////// -(int)(1.0 - (1 - (2 - (3 - (4 - (5 - (6 - (7 - (8 - 9)))))))));
175 public static int test_362880_float_mul_spill () {
176 // we overflow the FP stack
187 return (int)(1.0 * (a * (b * (c * (d * (e * (f * (g * (h * i)))))))));
190 public static int test_4_long_cast () {
192 double d = (double)a;
204 public static int test_4_ulong_cast () {
206 double d = (double)a;
210 a = 0xffffffffffffffff;
217 public static int test_4_single_long_cast () {
231 public static int test_0_lconv_to_r8 () {
233 double b = (double) a;
240 public static int test_0_lconv_to_r4 () {
249 static void doit (double value, out long m) {
253 public static int test_0_ftol_clobber () {
261 public static int test_0_rounding () {
262 long ticks = 631502475130080000L;
263 long ticksperday = 864000000000L;
265 double days = (double) ticks / ticksperday;
267 if ((int)days != 730905)
273 /* FIXME: This only works on little-endian machines */
275 static unsafe int test_2_negative_zero () {
280 byte *ptr = (byte*)&d;
294 public static int test_16_float_cmp () {
383 public static int test_15_float_cmp_un () {
384 double a = Double.NaN;
467 public static int test_15_float_branch () {
535 public static int test_15_float_branch_un () {
536 double a = Double.NaN;
603 public static int test_0_float_precision () {
604 float f1 = 3.40282346638528859E+38f;
605 float f2 = 3.40282346638528859E+38f;
606 float PositiveInfinity = 1.0f / 0.0f;
609 return f == PositiveInfinity ? 0 : 1;
613 Disabled until they can be fixed to run on amd64
615 static double VALUE = 0.19975845134874831D;
617 public static int test_0_float_conversion_reduces_double_precision () {
618 double d = (float)VALUE;
619 if (d != 0.19975845515727997d)
626 public static int test_0_long_to_double_conversion ()
628 long l = 9223372036854775807L;
629 long conv = (long)((double)l);
630 if (conv != -9223372036854775808L)
636 public static int INT_VAL = 0x13456799;
638 public static int test_0_int4_to_float_convertion ()
640 double d = (double)(float)INT_VAL;