OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/base/ieee754.h" | 7 #include "src/base/ieee754.h" |
8 #include "src/base/macros.h" | 8 #include "src/base/macros.h" |
9 #include "testing/gmock-support.h" | 9 #include "testing/gmock-support.h" |
10 #include "testing/gtest-support.h" | 10 #include "testing/gtest-support.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 atan2(std::numeric_limits<double>::infinity(), | 47 atan2(std::numeric_limits<double>::infinity(), |
48 -std::numeric_limits<double>::infinity())); | 48 -std::numeric_limits<double>::infinity())); |
49 EXPECT_DOUBLE_EQ(-0.7853981633974483, | 49 EXPECT_DOUBLE_EQ(-0.7853981633974483, |
50 atan2(-std::numeric_limits<double>::infinity(), | 50 atan2(-std::numeric_limits<double>::infinity(), |
51 std::numeric_limits<double>::infinity())); | 51 std::numeric_limits<double>::infinity())); |
52 EXPECT_DOUBLE_EQ(-2.356194490192345, | 52 EXPECT_DOUBLE_EQ(-2.356194490192345, |
53 atan2(-std::numeric_limits<double>::infinity(), | 53 atan2(-std::numeric_limits<double>::infinity(), |
54 -std::numeric_limits<double>::infinity())); | 54 -std::numeric_limits<double>::infinity())); |
55 } | 55 } |
56 | 56 |
57 TEST(Ieee754, Exp) { | |
58 EXPECT_THAT(exp(std::numeric_limits<double>::quiet_NaN()), IsNaN()); | |
59 EXPECT_THAT(exp(std::numeric_limits<double>::signaling_NaN()), IsNaN()); | |
60 EXPECT_EQ(0.0, exp(-std::numeric_limits<double>::infinity())); | |
61 EXPECT_EQ(0.0, exp(-1000)); | |
62 EXPECT_EQ(0.0, exp(-745.1332191019412)); | |
Raymond Toy
2016/06/16 18:12:44
DBC: It might be useful to add comments on what t
Benedikt Meurer
2016/06/16 18:13:53
May we ask you for help on these and the other fdl
Raymond Toy
2016/06/16 18:34:30
No problem. I'll look into them shortly. I see t
| |
63 EXPECT_EQ(2.2250738585072626e-308, exp(-708.39641853226408)); | |
64 EXPECT_EQ(3.307553003638408e-308, exp(-708.0)); | |
65 EXPECT_EQ(4.9406564584124654e-324, exp(-7.45133219101941108420e+02)); | |
66 EXPECT_EQ(0.36787944117144233, exp(-1.0)); | |
67 EXPECT_EQ(1.0, exp(-0.0)); | |
68 EXPECT_EQ(1.0, exp(0.0)); | |
69 EXPECT_EQ(1.0, exp(2.2250738585072014e-308)); | |
70 EXPECT_GE(exp(1.0), exp(0.9999999999999999)); | |
71 EXPECT_LE(exp(1.0), exp(1.0000000000000002)); | |
72 EXPECT_EQ(2.7182818284590455, exp(1.0)); | |
73 EXPECT_EQ(7.38905609893065e0, exp(2.0)); | |
74 EXPECT_EQ(1.7976931348622732e308, exp(7.09782712893383973096e+02)); | |
75 EXPECT_EQ(2.6881171418161356e+43, exp(100.0)); | |
76 EXPECT_EQ(8.218407461554972e+307, exp(709.0)); | |
77 EXPECT_EQ(1.7968190737295725e308, exp(709.7822265625e0)); | |
78 EXPECT_EQ(std::numeric_limits<double>::infinity(), exp(709.7827128933841e0)); | |
79 EXPECT_EQ(std::numeric_limits<double>::infinity(), exp(710.0)); | |
80 EXPECT_EQ(std::numeric_limits<double>::infinity(), exp(1000.0)); | |
81 EXPECT_EQ(std::numeric_limits<double>::infinity(), | |
82 exp(std::numeric_limits<double>::infinity())); | |
83 } | |
84 | |
57 TEST(Ieee754, Log) { | 85 TEST(Ieee754, Log) { |
58 EXPECT_THAT(log(std::numeric_limits<double>::quiet_NaN()), IsNaN()); | 86 EXPECT_THAT(log(std::numeric_limits<double>::quiet_NaN()), IsNaN()); |
59 EXPECT_THAT(log(std::numeric_limits<double>::signaling_NaN()), IsNaN()); | 87 EXPECT_THAT(log(std::numeric_limits<double>::signaling_NaN()), IsNaN()); |
60 EXPECT_THAT(log(-std::numeric_limits<double>::infinity()), IsNaN()); | 88 EXPECT_THAT(log(-std::numeric_limits<double>::infinity()), IsNaN()); |
61 EXPECT_THAT(log(-1.0), IsNaN()); | 89 EXPECT_THAT(log(-1.0), IsNaN()); |
62 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(-0.0)); | 90 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(-0.0)); |
63 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(0.0)); | 91 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(0.0)); |
64 EXPECT_EQ(0.0, log(1.0)); | 92 EXPECT_EQ(0.0, log(1.0)); |
65 EXPECT_EQ(std::numeric_limits<double>::infinity(), | 93 EXPECT_EQ(std::numeric_limits<double>::infinity(), |
66 log(std::numeric_limits<double>::infinity())); | 94 log(std::numeric_limits<double>::infinity())); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 EXPECT_EQ(3.0, log10(1000.0)); | 142 EXPECT_EQ(3.0, log10(1000.0)); |
115 EXPECT_EQ(14.0, log10(100000000000000)); // log10(10 ^ 14) | 143 EXPECT_EQ(14.0, log10(100000000000000)); // log10(10 ^ 14) |
116 EXPECT_EQ(3.7389561269540406, log10(5482.2158)); | 144 EXPECT_EQ(3.7389561269540406, log10(5482.2158)); |
117 EXPECT_EQ(14.661551142893833, log10(458723662312872.125782332587)); | 145 EXPECT_EQ(14.661551142893833, log10(458723662312872.125782332587)); |
118 EXPECT_EQ(-0.9083828622192334, log10(0.12348583358871)); | 146 EXPECT_EQ(-0.9083828622192334, log10(0.12348583358871)); |
119 } | 147 } |
120 | 148 |
121 } // namespace ieee754 | 149 } // namespace ieee754 |
122 } // namespace base | 150 } // namespace base |
123 } // namespace v8 | 151 } // namespace v8 |
OLD | NEW |