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 /* Regression test for #30073 */
96 public static int test_0_newarr_emulation () {
99 double [] arr = new double [(int)d];
104 private Int32[] m_array = new int [10];
106 void setBit (int bitIndex, bool value) {
107 int index = bitIndex/32;
108 int shift = bitIndex%32;
110 Int32 theBit = 1 << shift;
112 m_array[index] |= theBit;
114 m_array[index] &= ~theBit;
117 bool getBit (int bitIndex) {
118 int index = bitIndex/32;
119 int shift = bitIndex%32;
121 Int32 theBit = m_array[index] & (1 << shift);
122 return (theBit == 0) ? false : true;
126 public static int test_1_bit_index () {
127 Tests t = new Tests ();
141 int [] ma = new int [56];
142 const int MBIG = int.MaxValue;
145 for (int k = 1; k < 5; k++) {
146 for (int i = 1; i < 56; i++) {
147 ma [i] -= ma [1 + (i + 30) % 55];
155 public static int test_2_regalloc () {
156 helper1 h = new helper1 ();