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;
100 public static int test_5_conv_r4 () {
106 public static int test_0_conv_r4_m1 () {
112 public static int test_5_double_conv_r4 () {
118 public static int test_5_float_conv_r8 () {
120 double d = (double)f;
124 public static int test_5_conv_r8 () {
126 double f = (double)i;
130 public static int test_5_add () {
136 public static int test_5_sub () {
142 public static int test_24_mul () {
148 public static int test_4_div () {
154 public static int test_2_rem () {
160 public static int test_2_neg () {
165 public static int test_46_float_add_spill () {
166 // we overflow the FP stack
177 return (int)(1.0 + (a + (b + (c + (d + (e + (f + (g + (h + i)))))))));
180 public static int test_4_float_sub_spill () {
181 // we overflow the FP stack
192 return -(int)(1.0 - (a - (b - (c - (d - (e - (f - (g - (h - i)))))))));
193 ////// -(int)(1.0 - (1 - (2 - (3 - (4 - (5 - (6 - (7 - (8 - 9)))))))));
196 public static int test_362880_float_mul_spill () {
197 // we overflow the FP stack
208 return (int)(1.0 * (a * (b * (c * (d * (e * (f * (g * (h * i)))))))));
211 public static int test_4_long_cast () {
213 double d = (double)a;
225 public static int test_4_ulong_cast () {
227 double d = (double)a;
231 a = 0xffffffffffffffff;
238 public static int test_4_single_long_cast () {
252 public static int test_0_lconv_to_r8 () {
254 double b = (double) a;
261 public static int test_0_lconv_to_r4 () {
270 static void doit (double value, out long m) {
274 public static int test_0_ftol_clobber () {
282 public static int test_0_rounding () {
283 long ticks = 631502475130080000L;
284 long ticksperday = 864000000000L;
286 double days = (double) ticks / ticksperday;
288 if ((int)days != 730905)
294 /* FIXME: This only works on little-endian machines */
296 static unsafe int test_2_negative_zero () {
301 byte *ptr = (byte*)&d;
315 public static int test_16_float_cmp () {
404 public static int test_15_float_cmp_un () {
405 double a = Double.NaN;
488 public static int test_15_float_branch () {
556 public static int test_15_float_branch_un () {
557 double a = Double.NaN;
624 public static int test_0_float_precision () {
625 float f1 = 3.40282346638528859E+38f;
626 float f2 = 3.40282346638528859E+38f;
627 float PositiveInfinity = 1.0f / 0.0f;
630 return f == PositiveInfinity ? 0 : 1;
633 static double VALUE = 0.19975845134874831D;
635 public static int test_0_float_conversion_reduces_double_precision () {
636 double d = (float)VALUE;
637 if (d != 0.19975845515727997d)
644 public static int test_0_long_to_double_conversion ()
646 long l = 9223372036854775807L;
647 long conv = (long)((double)l);
648 if (conv != -9223372036854775808L)
654 public static int INT_VAL = 0x13456799;
656 public static int test_0_int4_to_float_convertion ()
658 double d = (double)(float)INT_VAL;
665 public static int test_0_int8_to_float_convertion ()
667 double d = (double)(float)(long)INT_VAL;