* roottypes.cs: Rename from tree.cs.
[mono.git] / mono / tests / jit-long.cs
1 using System;
2
3 public class TestJit {
4
5         public static long test_call (long a, long b) {
6                 return a+b;
7         }
8
9         public static int test_shift_1 ()
10         {
11                 long a = 9;
12                 int b = 1;
13                 
14                 if ((a >> b) != 4)
15                         return 1;
16                 
17                 if ((a >> 63) != 0)
18                         return 1;
19
20                 if ((a << 1) != 18)
21                         return 1;
22
23                 if ((a << b) != 18)
24                         return 1;
25
26                 a = -9;
27                 if ((a >> b) != -5)
28                         return 1;
29
30                 return 0;
31         }
32
33         public static int test_shift_2 ()
34         {
35                 unchecked {
36                         long c = (long)0x800000ff00000000;
37                         long d = (long)0x8ef0abcd00000000;
38                         long t;
39                         int sa;
40                         
41                         t = c>>4;
42                         Console.WriteLine (t.ToString ("X"));
43                         if (t != (long)0xf800000ff0000000)
44                                 return 1;
45
46                         if ((t << 4) != c)
47                                 return 1;
48                         
49                         t = d>>40;
50                         Console.WriteLine (t.ToString ("X"));
51                         if (t != (long)0xffffffffff8ef0ab)
52                                 return 1;
53
54                         if ((t << 40) != (long)0x8ef0ab0000000000)
55                                 return 1;
56                         
57                         
58                 }
59                 
60                 return 0;
61         }
62
63         public static int test_shift_3 ()
64         {
65                 checked {
66                         ulong c = 0x800000ff00000000;
67                         ulong d = 0x8ef0abcd00000000;
68                         ulong t;
69                         
70                         t = c >> 4;
71                         Console.WriteLine (t.ToString ("X"));
72                         if (t != 0x0800000ff0000000)
73                                 return 1;
74
75                         if ((t << 4) != c)
76                                 return 1;
77                         
78                         t = d >> 40;
79                         Console.WriteLine (t.ToString ("X"));
80                         if (t != 0x8ef0ab)
81                                 return 1;
82
83                         if ((t << 40) != 0x8ef0ab0000000000)
84                                 return 1;
85                 }
86
87                 return 0;
88         }
89
90         public static int test_alu ()
91         {
92                 long a = 9, b = 6;
93                 
94                 if ((a + b) != 15)
95                         return 1;
96                 
97                 if ((a - b) != 3)
98                         return 1;
99
100                 if ((a & 8) != 8)
101                         return 1;
102
103                 if ((a | 2) != 11)
104                         return 1;
105
106                 if ((a * b) != 54)
107                         return 1;
108                 
109                 if ((a / 4) != 2)
110                         return 1;
111                 
112                 if ((a % 4) != 1)
113                         return 1;
114
115                 if (-a != -9)
116                         return 1;
117
118                 b = -1;
119                 if (~b != 0)
120                         return 1;
121
122                 return 0;
123         }
124         
125         public static int test_branch ()
126         {
127                 long a = 5, b = 5, t;
128                 
129                 if (a == b) t = 1; else t = 0;
130                 if (t != 1) return 1;
131
132                 if (a != b) t = 0; else t = 1;
133                 if (t != 1) return 1;
134
135                 if (a >= b) t = 1; else t = 0;
136                 if (t != 1) return 1;
137
138                 if (a > b) t = 0; else t = 1;
139                 if (t != 1) return 1;
140
141                 if (a <= b) t = 1; else t = 0;
142                 if (t != 1) return 1;
143
144                 if (a < b) t = 0; else t = 1;
145                 if (t != 1) return 1;
146
147                 return 0;
148         }
149
150         public static int Main() {
151                 int num = 0;
152
153                 num++;
154                 if (test_shift_1 () != 0)
155                         return num;
156                 num++;
157                 if (test_shift_2 () != 0)
158                         return num;
159                 num++;
160                 if (test_shift_3 () != 0)
161                         return num;
162                 
163                 num++;
164                 if (test_call (3, 5) != 8)
165                         return num;
166
167                 num++;
168                 if (test_branch () != 0)
169                         return num;
170
171                 num++;
172                 if (test_alu () != 0)
173                         return num;
174                 
175                 return 0;
176         }
177 }
178