2007-03-28 Chris Toshok <toshok@ximian.com>
[mono-project.git] / mono / tests / jit-int.cs
blob6cb0f2127b3e94a74ece765e20c49c856996f0b6
1 using System;
3 public class TestJit {
5 public static int test_short ()
7 int max = 32767;
8 int min = -32768;
10 int t1 = 0xffeedd;
11 short s1 = (short)t1;
12 int t2 = s1;
14 if ((uint)t2 != 0xffffeedd)
15 return 1;
17 Console.WriteLine (t2.ToString ("X"));
19 if (Int16.Parse((min).ToString()) != -32768)
20 return 1;
22 if (Int16.Parse((max).ToString()) != 32767)
23 return 1;
25 return 0;
28 public static int test_call (int a, int b) {
29 return a+b;
32 public static int test_shift ()
34 int a = 9, b = 1;
36 if ((a << 1) != 18)
37 return 1;
39 if ((a << b) != 18)
40 return 1;
42 if ((a >> 1) != 4)
43 return 1;
45 if ((a >> b) != 4)
46 return 1;
48 a = -9;
49 if ((a >> b) != -5)
50 return 1;
52 return 0;
55 public static int test_alu ()
57 int a = 9, b = 6;
59 if ((a + b) != 15)
60 return 1;
62 if ((a - b) != 3)
63 return 1;
65 if ((a & 8) != 8)
66 return 1;
68 if ((a | 2) != 11)
69 return 1;
71 if ((a * b) != 54)
72 return 1;
74 if ((a / 4) != 2)
75 return 1;
77 if ((a % 4) != 1)
78 return 1;
80 if (-a != -9)
81 return 1;
83 b = -1;
84 if (~b != 0)
85 return 1;
87 return 0;
90 public static int test_branch ()
92 int a = 5, b = 5, t;
94 if (a == b) t = 1; else t = 0;
95 if (t != 1) return 1;
97 if (a != b) t = 0; else t = 1;
98 if (t != 1) return 1;
100 if (a >= b) t = 1; else t = 0;
101 if (t != 1) return 1;
103 if (a > b) t = 0; else t = 1;
104 if (t != 1) return 1;
106 if (a <= b) t = 1; else t = 0;
107 if (t != 1) return 1;
109 if (a < b) t = 0; else t = 1;
110 if (t != 1) return 1;
112 return 0;
115 public static int Main() {
116 int num = 0;
118 num++;
119 if (test_short () != 0)
120 return num;
122 num++;
123 if (test_call (3, 5) != 8)
124 return num;
125 num++;
127 if (test_branch () != 0)
128 return num;
129 num++;
131 if (test_alu () != 0)
132 return num;
133 num++;
135 if (test_shift () != 0)
136 return num;
137 num++;
139 return 0;