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;
213 public static int test_4_single_long_cast () {
227 public static int test_0_lconv_to_r8 () {
229 double b = (double) a;
236 public static int test_0_lconv_to_r4 () {
245 static void doit (double value, out long m) {
249 public static int test_0_ftol_clobber () {
257 public static int test_0_rounding () {
258 long ticks = 631502475130080000L;
259 long ticksperday = 864000000000L;
261 double days = (double) ticks / ticksperday;
263 if ((int)days != 730905)
269 /* FIXME: This only works on little-endian machines */
271 static unsafe int test_2_negative_zero () {
276 byte *ptr = (byte*)&d;
290 public static int test_16_float_cmp () {
379 public static int test_15_float_cmp_un () {
380 double a = Double.NaN;
463 public static int test_15_float_branch () {
531 public static int test_15_float_branch_un () {
532 double a = Double.NaN;
599 public static int test_0_float_precision () {
600 float f1 = 3.40282346638528859E+38f;
601 float f2 = 3.40282346638528859E+38f;
602 float PositiveInfinity = 1.0f / 0.0f;
605 return f == PositiveInfinity ? 0 : 1;
609 Disabled until they can be fixed to run on amd64
611 static double VALUE = 0.19975845134874831D;
613 public static int test_0_float_conversion_reduces_double_precision () {
614 double d = (float)VALUE;
615 if (d != 0.19975845515727997d)
622 public static int test_0_long_to_double_conversion ()
624 long l = 9223372036854775807L;
625 long conv = (long)((double)l);
626 if (conv != -9223372036854775808L)
632 public static int INT_VAL = 0x13456799;
634 public static int test_0_int4_to_float_convertion ()
636 double d = (double)(float)INT_VAL;