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_0_beq () {
39 static int test_0_bne_un () {
46 static int test_0_conv_r8 () {
53 static int test_0_conv_i () {
64 ushort us = (ushort)a;
73 static int test_5_conv_r4 () {
79 static int test_5_double_conv_r4 () {
85 static int test_5_float_conv_r8 () {
91 static int test_5_conv_r8 () {
97 static int test_5_add () {
103 static int test_5_sub () {
109 static int test_24_mul () {
115 static int test_4_div () {
121 static int test_2_rem () {
127 static int test_2_neg () {
132 static int test_46_float_add_spill () {
133 // we overflow the FP stack
144 return (int)(1.0 + (a + (b + (c + (d + (e + (f + (g + (h + i)))))))));
147 static int test_4_float_sub_spill () {
148 // we overflow the FP stack
159 return -(int)(1.0 - (a - (b - (c - (d - (e - (f - (g - (h - i)))))))));
160 ////// -(int)(1.0 - (1 - (2 - (3 - (4 - (5 - (6 - (7 - (8 - 9)))))))));
163 static int test_362880_float_mul_spill () {
164 // we overflow the FP stack
175 return (int)(1.0 * (a * (b * (c * (d * (e * (f * (g * (h * i)))))))));
178 static int test_4_long_cast () {
180 double d = (double)a;
192 public static int test_0_rounding () {
193 long ticks = 631502475130080000L;
194 long ticksperday = 864000000000L;
196 double days = (double) ticks / ticksperday;
198 if ((int)days != 730905)
204 /* FIXME: This only works on little-endian machines */
206 static unsafe int test_2_negative_zero () {
211 byte *ptr = (byte*)&d;
225 static int test_16_float_cmp () {
314 static int test_15_float_cmp_un () {
315 double a = Double.NaN;
398 static int test_15_float_branch () {
466 static int test_15_float_branch_un () {
467 double a = Double.NaN;