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" |
11 | 11 |
| 12 using testing::BitEq; |
12 using testing::IsNaN; | 13 using testing::IsNaN; |
13 | 14 |
14 namespace v8 { | 15 namespace v8 { |
15 namespace base { | 16 namespace base { |
16 namespace ieee754 { | 17 namespace ieee754 { |
17 | 18 |
| 19 TEST(Ieee754, Atan) { |
| 20 EXPECT_THAT(atan(std::numeric_limits<double>::quiet_NaN()), IsNaN()); |
| 21 EXPECT_THAT(atan(std::numeric_limits<double>::signaling_NaN()), IsNaN()); |
| 22 EXPECT_THAT(atan(-0.0), BitEq(-0.0)); |
| 23 EXPECT_THAT(atan(0.0), BitEq(0.0)); |
| 24 EXPECT_DOUBLE_EQ(1.5707963267948966, |
| 25 atan(std::numeric_limits<double>::infinity())); |
| 26 EXPECT_DOUBLE_EQ(-1.5707963267948966, |
| 27 atan(-std::numeric_limits<double>::infinity())); |
| 28 } |
| 29 |
| 30 TEST(Ieee754, Atan2) { |
| 31 EXPECT_THAT(atan2(std::numeric_limits<double>::quiet_NaN(), |
| 32 std::numeric_limits<double>::quiet_NaN()), |
| 33 IsNaN()); |
| 34 EXPECT_THAT(atan2(std::numeric_limits<double>::quiet_NaN(), |
| 35 std::numeric_limits<double>::signaling_NaN()), |
| 36 IsNaN()); |
| 37 EXPECT_THAT(atan2(std::numeric_limits<double>::signaling_NaN(), |
| 38 std::numeric_limits<double>::quiet_NaN()), |
| 39 IsNaN()); |
| 40 EXPECT_THAT(atan2(std::numeric_limits<double>::signaling_NaN(), |
| 41 std::numeric_limits<double>::signaling_NaN()), |
| 42 IsNaN()); |
| 43 EXPECT_DOUBLE_EQ(0.7853981633974483, |
| 44 atan2(std::numeric_limits<double>::infinity(), |
| 45 std::numeric_limits<double>::infinity())); |
| 46 EXPECT_DOUBLE_EQ(2.356194490192345, |
| 47 atan2(std::numeric_limits<double>::infinity(), |
| 48 -std::numeric_limits<double>::infinity())); |
| 49 EXPECT_DOUBLE_EQ(-0.7853981633974483, |
| 50 atan2(-std::numeric_limits<double>::infinity(), |
| 51 std::numeric_limits<double>::infinity())); |
| 52 EXPECT_DOUBLE_EQ(-2.356194490192345, |
| 53 atan2(-std::numeric_limits<double>::infinity(), |
| 54 -std::numeric_limits<double>::infinity())); |
| 55 } |
| 56 |
18 TEST(Ieee754, Log) { | 57 TEST(Ieee754, Log) { |
19 EXPECT_THAT(log(std::numeric_limits<double>::quiet_NaN()), IsNaN()); | 58 EXPECT_THAT(log(std::numeric_limits<double>::quiet_NaN()), IsNaN()); |
20 EXPECT_THAT(log(std::numeric_limits<double>::signaling_NaN()), IsNaN()); | 59 EXPECT_THAT(log(std::numeric_limits<double>::signaling_NaN()), IsNaN()); |
21 EXPECT_THAT(log(-std::numeric_limits<double>::infinity()), IsNaN()); | 60 EXPECT_THAT(log(-std::numeric_limits<double>::infinity()), IsNaN()); |
22 EXPECT_THAT(log(-1.0), IsNaN()); | 61 EXPECT_THAT(log(-1.0), IsNaN()); |
23 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(-0.0)); | 62 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(-0.0)); |
24 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(0.0)); | 63 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(0.0)); |
25 EXPECT_EQ(0.0, log(1.0)); | 64 EXPECT_EQ(0.0, log(1.0)); |
26 EXPECT_EQ(std::numeric_limits<double>::infinity(), | 65 EXPECT_EQ(std::numeric_limits<double>::infinity(), |
27 log(std::numeric_limits<double>::infinity())); | 66 log(std::numeric_limits<double>::infinity())); |
(...skipping 20 matching lines...) Expand all Loading... |
48 EXPECT_EQ(37.08336444902049, log1p(12737979646738432)); | 87 EXPECT_EQ(37.08336444902049, log1p(12737979646738432)); |
49 EXPECT_EQ(1.3862943611198906, log1p(3)); | 88 EXPECT_EQ(1.3862943611198906, log1p(3)); |
50 EXPECT_EQ(1.3862945995384413, log1p(3 + 9.5367431640625e-7)); | 89 EXPECT_EQ(1.3862945995384413, log1p(3 + 9.5367431640625e-7)); |
51 EXPECT_EQ(0.5596157879354227, log1p(0.75)); | 90 EXPECT_EQ(0.5596157879354227, log1p(0.75)); |
52 EXPECT_EQ(0.8109302162163288, log1p(1.25)); | 91 EXPECT_EQ(0.8109302162163288, log1p(1.25)); |
53 } | 92 } |
54 | 93 |
55 } // namespace ieee754 | 94 } // namespace ieee754 |
56 } // namespace base | 95 } // namespace base |
57 } // namespace v8 | 96 } // namespace v8 |
OLD | NEW |