SHR/SHL impl.
[mono.git] / mono / tests / jit-long.cs
1 public class TestJit {
2
3         public static long test_call (long a, long b) {
4                 return a+b;
5         }
6
7         public static int test_shift ()
8         {
9                 long a = 9;
10                 int b = 1;
11
12                 if ((a >> b) != 4)
13                         return 1;
14                 
15                 if ((a >> 63) != 0)
16                         return 1;
17
18                 if ((a << 1) != 18)
19                         return 1;
20
21                 if ((a << b) != 18)
22                         return 1;
23
24                 a = -9;
25                 if ((a >> b) != -5)
26                         return 1;
27
28                 return 0;
29         }
30
31         public static int test_alu ()
32         {
33                 long a = 9, b = 6;
34                 
35                 if ((a + b) != 15)
36                         return 1;
37                 
38                 if ((a - b) != 3)
39                         return 1;
40
41                 if ((a & 8) != 8)
42                         return 1;
43
44                 if ((a | 2) != 11)
45                         return 1;
46
47                 if ((a * b) != 54)
48                         return 1;
49                 
50                 if ((a / 4) != 2)
51                         return 1;
52                 
53                 if ((a % 4) != 1)
54                         return 1;
55
56                 if (-a != -9)
57                         return 1;
58
59                 b = -1;
60                 if (~b != 0)
61                         return 1;
62
63                 return 0;
64         }
65         
66         public static int test_branch ()
67         {
68                 long a = 5, b = 5, t;
69                 
70                 if (a == b) t = 1; else t = 0;
71                 if (t != 1) return 1;
72
73                 if (a != b) t = 0; else t = 1;
74                 if (t != 1) return 1;
75
76                 if (a >= b) t = 1; else t = 0;
77                 if (t != 1) return 1;
78
79                 if (a > b) t = 0; else t = 1;
80                 if (t != 1) return 1;
81
82                 if (a <= b) t = 1; else t = 0;
83                 if (t != 1) return 1;
84
85                 if (a < b) t = 0; else t = 1;
86                 if (t != 1) return 1;
87
88                 return 0;
89         }
90
91         public static int Main() {
92                 int num = 1;
93
94                 if (test_shift () != 0)
95                         return num;
96                 num++;
97                 if (test_call (3, 5) != 8)
98                         return num;
99                 num++;
100
101                 if (test_branch () != 0)
102                         return num;
103                 num++;
104                 
105                 if (test_alu () != 0)
106                         return num;
107                 num++;
108                 
109                 return 0;
110         }
111 }
112