OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "platform.h" | 7 #include "platform.h" |
8 #include "cctest.h" | 8 #include "cctest.h" |
9 #include "diy-fp.h" | 9 #include "diy-fp.h" |
10 #include "double.h" | 10 #include "double.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 CHECK(!Double(OS::nan_value()).IsInfinite()); | 105 CHECK(!Double(OS::nan_value()).IsInfinite()); |
106 CHECK(!Double(0.0).IsInfinite()); | 106 CHECK(!Double(0.0).IsInfinite()); |
107 CHECK(!Double(-0.0).IsInfinite()); | 107 CHECK(!Double(-0.0).IsInfinite()); |
108 CHECK(!Double(1.0).IsInfinite()); | 108 CHECK(!Double(1.0).IsInfinite()); |
109 CHECK(!Double(-1.0).IsInfinite()); | 109 CHECK(!Double(-1.0).IsInfinite()); |
110 uint64_t min_double64 = V8_2PART_UINT64_C(0x00000000, 00000001); | 110 uint64_t min_double64 = V8_2PART_UINT64_C(0x00000000, 00000001); |
111 CHECK(!Double(min_double64).IsInfinite()); | 111 CHECK(!Double(min_double64).IsInfinite()); |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 TEST(IsNan) { | |
116 CHECK(Double(OS::nan_value()).IsNan()); | |
117 uint64_t other_nan = V8_2PART_UINT64_C(0xFFFFFFFF, 00000001); | |
118 CHECK(Double(other_nan).IsNan()); | |
119 CHECK(!Double(V8_INFINITY).IsNan()); | |
120 CHECK(!Double(-V8_INFINITY).IsNan()); | |
121 CHECK(!Double(0.0).IsNan()); | |
122 CHECK(!Double(-0.0).IsNan()); | |
123 CHECK(!Double(1.0).IsNan()); | |
124 CHECK(!Double(-1.0).IsNan()); | |
125 uint64_t min_double64 = V8_2PART_UINT64_C(0x00000000, 00000001); | |
126 CHECK(!Double(min_double64).IsNan()); | |
127 } | |
128 | |
129 | |
130 TEST(Sign) { | 115 TEST(Sign) { |
131 CHECK_EQ(1, Double(1.0).Sign()); | 116 CHECK_EQ(1, Double(1.0).Sign()); |
132 CHECK_EQ(1, Double(V8_INFINITY).Sign()); | 117 CHECK_EQ(1, Double(V8_INFINITY).Sign()); |
133 CHECK_EQ(-1, Double(-V8_INFINITY).Sign()); | 118 CHECK_EQ(-1, Double(-V8_INFINITY).Sign()); |
134 CHECK_EQ(1, Double(0.0).Sign()); | 119 CHECK_EQ(1, Double(0.0).Sign()); |
135 CHECK_EQ(-1, Double(-0.0).Sign()); | 120 CHECK_EQ(-1, Double(-0.0).Sign()); |
136 uint64_t min_double64 = V8_2PART_UINT64_C(0x00000000, 00000001); | 121 uint64_t min_double64 = V8_2PART_UINT64_C(0x00000000, 00000001); |
137 CHECK_EQ(1, Double(min_double64).Sign()); | 122 CHECK_EQ(1, Double(min_double64).Sign()); |
138 } | 123 } |
139 | 124 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 Double d0(-4e-324); | 196 Double d0(-4e-324); |
212 Double d1(d0.NextDouble()); | 197 Double d1(d0.NextDouble()); |
213 Double d2(d1.NextDouble()); | 198 Double d2(d1.NextDouble()); |
214 CHECK_EQ(-0.0, d1.value()); | 199 CHECK_EQ(-0.0, d1.value()); |
215 CHECK_EQ(0.0, d2.value()); | 200 CHECK_EQ(0.0, d2.value()); |
216 CHECK_EQ(4e-324, d2.NextDouble()); | 201 CHECK_EQ(4e-324, d2.NextDouble()); |
217 CHECK_EQ(-1.7976931348623157e308, Double(-V8_INFINITY).NextDouble()); | 202 CHECK_EQ(-1.7976931348623157e308, Double(-V8_INFINITY).NextDouble()); |
218 CHECK_EQ(V8_INFINITY, | 203 CHECK_EQ(V8_INFINITY, |
219 Double(V8_2PART_UINT64_C(0x7fefffff, ffffffff)).NextDouble()); | 204 Double(V8_2PART_UINT64_C(0x7fefffff, ffffffff)).NextDouble()); |
220 } | 205 } |
OLD | NEW |