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
;
76 static int test_5_conv_r4 () {
82 static int test_5_double_conv_r4 () {
88 static int test_5_float_conv_r8 () {
94 static int test_5_conv_r8 () {
100 static int test_5_add () {
106 static int test_5_sub () {
112 static int test_24_mul () {
118 static int test_4_div () {
124 static int test_2_rem () {
130 static int test_2_neg () {
135 static int test_46_float_add_spill () {
136 // we overflow the FP stack
147 return (int)(1.0 + (a
+ (b
+ (c
+ (d
+ (e
+ (f
+ (g
+ (h
+ i
)))))))));
150 static int test_4_float_sub_spill () {
151 // we overflow the FP stack
162 return -(int)(1.0 - (a
- (b
- (c
- (d
- (e
- (f
- (g
- (h
- i
)))))))));
163 ////// -(int)(1.0 - (1 - (2 - (3 - (4 - (5 - (6 - (7 - (8 - 9)))))))));
166 static int test_362880_float_mul_spill () {
167 // we overflow the FP stack
178 return (int)(1.0 * (a
* (b
* (c
* (d
* (e
* (f
* (g
* (h
* i
)))))))));
181 static int test_4_long_cast () {
183 double d
= (double)a
;
195 static int test_4_single_long_cast () {
209 public static int test_0_rounding () {
210 long ticks
= 631502475130080000L;
211 long ticksperday
= 864000000000L;
213 double days
= (double) ticks
/ ticksperday
;
215 if ((int)days
!= 730905)
221 /* FIXME: This only works on little-endian machines */
223 static unsafe int test_2_negative_zero () {
228 byte *ptr = (byte*)&d;
242 static int test_16_float_cmp () {
331 static int test_15_float_cmp_un () {
332 double a
= Double
.NaN
;
415 static int test_15_float_branch () {
483 static int test_15_float_branch_un () {
484 double a
= Double
.NaN
;
551 static int test_0_float_precision () {
552 float f1
= 3.40282346638528859E+38f
;
553 float f2
= 3.40282346638528859E+38f
;
554 float PositiveInfinity
= 1.0f
/ 0.0f
;
557 return f
== PositiveInfinity
? 0 : 1;