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_10_create () {
33 int[] a = new int [10];
37 static int test_0_unset_value () {
38 int[] a = new int [10];
42 static int test_3_set_value () {
43 int[] a = new int [10];
48 static int test_0_char_array_1 () {
50 char[] tmp = new char [20];
51 char[] digitLowerTable = new char[16];
52 tmp[0] = digitLowerTable[-(value % 10)];
56 static int test_0_char_array_2 () {
58 char[] tmp = new char [20];
59 char[] digitLowerTable = new char[16];
60 tmp[0] = digitLowerTable[value % 10];
64 static int test_0_char_array_3 () {
66 char[] tmp = new char [20];
67 char[] digitLowerTable = new char[16];
68 tmp [0] = digitLowerTable[value & 15];
72 unsafe static int test_0_byte_array () {
73 byte [] src = new byte [8];
75 byte *dst = (byte *)&ret;
78 dst[0] = src[4 + start];
83 public static int test_0_set_after_shift () {
84 int [] n = new int [1];
87 n [0] = 100 + (1 << (16 - b));
95 private Int32[] m_array = new int [10];
97 void setBit (int bitIndex, bool value) {
98 int index = bitIndex/32;
99 int shift = bitIndex%32;
101 Int32 theBit = 1 << shift;
103 m_array[index] |= theBit;
105 m_array[index] &= ~theBit;
108 bool getBit (int bitIndex) {
109 int index = bitIndex/32;
110 int shift = bitIndex%32;
112 Int32 theBit = m_array[index] & (1 << shift);
113 return (theBit == 0) ? false : true;
117 public static int test_1_bit_index () {
118 Tests t = new Tests ();
132 int [] ma = new int [56];
133 const int MBIG = int.MaxValue;
136 for (int k = 1; k < 5; k++) {
137 for (int i = 1; i < 56; i++) {
138 ma [i] -= ma [1 + (i + 30) % 55];
146 public static int test_2_regalloc () {
147 helper1 h = new helper1 ();