update readme (#21797)
[mono-project.git] / mono / tests / jit-float.cs
blobc908dff627d7777b19040866e2a549d76888f602
1 using System;
3 public class TestJit {
5 public static int test_nan ()
7 double nan1 = Double.NaN;
8 double nan2 = Double.NaN;
9 double neg_inf1 = Double.NegativeInfinity;
10 double neg_inf2 = Double.NegativeInfinity;
11 double pos_inf1 = Double.PositiveInfinity;
12 double pos_inf2 = Double.PositiveInfinity;
13 int err = 1;
15 if (nan1 == nan2)
16 return err;
17 err++;
19 if (!nan1.Equals(nan2))
20 return err;
22 err++;
23 if (neg_inf1 != neg_inf2)
24 return err;
26 err++;
27 if (!neg_inf1.Equals(neg_inf2))
28 return err;
30 err++;
31 if (pos_inf1 != pos_inf2)
32 return err;
34 err++;
35 if (!pos_inf1.Equals(pos_inf2))
36 return err;
38 err++;
39 if (pos_inf1 == neg_inf1)
40 return err;
42 err++;
43 if (pos_inf1.Equals (neg_inf1))
44 return err;
46 err++;
47 if (pos_inf1 == nan1)
48 return err;
50 return 0;
53 public static double test_call (double a, double b) {
54 return a+b;
57 public static int test_alu ()
59 double a = 9, b = 6;
60 int err = 1;
62 if ((a + b) != 15)
63 return err;
65 err++;
66 if ((a - b) != 3)
67 return err;
69 err++;
70 if ((a * b) != 54)
71 return err;
73 err++;
74 if ((a / 4) != 2.25)
75 return err;
77 err++;
78 if ((a % 4) != 1)
79 return err;
81 err++;
82 if (-a != -9)
83 return err;
85 return 0;
88 public static int test_branch ()
90 double a = 0.5, b = 0.5, t;
91 int err = 1;
93 if (a == b) t = 1; else t = 0;
94 if (t != 1) return err;
96 err++;
97 if (a != b) t = 0; else t = 1;
98 if (t != 1) return err;
100 err++;
101 if (a >= b) t = 1; else t = 0;
102 if (t != 1) return err;
104 err++;
105 if (a > b) t = 0; else t = 1;
106 if (t != 1) return err;
108 err++;
109 if (a <= b) t = 1; else t = 0;
110 if (t != 1) return err;
112 err++;
113 if (a < b) t = 0; else t = 1;
114 if (t != 1) return err;
116 err++;
117 if (a > 1.0) return err;
119 err++;
120 if (a < 0.1) return err;
122 return 0;
125 public static int Main() {
126 int num = 1;
128 if (test_call (3, 5) != 8)
129 return num;
130 num++;
132 if (test_branch () != 0)
133 return num;
134 num++;
136 if (test_alu () != 0)
137 return num;
138 num++;
140 if (test_nan () != 0)
141 return num;
142 num++;
145 return 0;