Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: test/unittests/base/ieee754-unittest.cc

Issue 2068743002: [builtins] Unify Atanh, Cbrt and Expm1 as exports from flibm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed type warning. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/compiler/test-run-machops.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, Atanh) {
58 EXPECT_THAT(atanh(std::numeric_limits<double>::quiet_NaN()), IsNaN());
59 EXPECT_THAT(atanh(std::numeric_limits<double>::signaling_NaN()), IsNaN());
60 EXPECT_THAT(atanh(std::numeric_limits<double>::infinity()), IsNaN());
61 EXPECT_EQ(std::numeric_limits<double>::infinity(), atanh(1));
62 EXPECT_EQ(-std::numeric_limits<double>::infinity(), atanh(-1));
63 EXPECT_DOUBLE_EQ(0.54930614433405478, atanh(0.5));
64 }
65
57 TEST(Ieee754, Exp) { 66 TEST(Ieee754, Exp) {
58 EXPECT_THAT(exp(std::numeric_limits<double>::quiet_NaN()), IsNaN()); 67 EXPECT_THAT(exp(std::numeric_limits<double>::quiet_NaN()), IsNaN());
59 EXPECT_THAT(exp(std::numeric_limits<double>::signaling_NaN()), IsNaN()); 68 EXPECT_THAT(exp(std::numeric_limits<double>::signaling_NaN()), IsNaN());
60 EXPECT_EQ(0.0, exp(-std::numeric_limits<double>::infinity())); 69 EXPECT_EQ(0.0, exp(-std::numeric_limits<double>::infinity()));
61 EXPECT_EQ(0.0, exp(-1000)); 70 EXPECT_EQ(0.0, exp(-1000));
62 EXPECT_EQ(0.0, exp(-745.1332191019412)); 71 EXPECT_EQ(0.0, exp(-745.1332191019412));
63 EXPECT_EQ(2.2250738585072626e-308, exp(-708.39641853226408)); 72 EXPECT_EQ(2.2250738585072626e-308, exp(-708.39641853226408));
64 EXPECT_EQ(3.307553003638408e-308, exp(-708.0)); 73 EXPECT_EQ(3.307553003638408e-308, exp(-708.0));
65 EXPECT_EQ(4.9406564584124654e-324, exp(-7.45133219101941108420e+02)); 74 EXPECT_EQ(4.9406564584124654e-324, exp(-7.45133219101941108420e+02));
66 EXPECT_EQ(0.36787944117144233, exp(-1.0)); 75 EXPECT_EQ(0.36787944117144233, exp(-1.0));
67 EXPECT_EQ(1.0, exp(-0.0)); 76 EXPECT_EQ(1.0, exp(-0.0));
68 EXPECT_EQ(1.0, exp(0.0)); 77 EXPECT_EQ(1.0, exp(0.0));
69 EXPECT_EQ(1.0, exp(2.2250738585072014e-308)); 78 EXPECT_EQ(1.0, exp(2.2250738585072014e-308));
70 EXPECT_GE(exp(1.0), exp(0.9999999999999999)); 79 EXPECT_GE(exp(1.0), exp(0.9999999999999999));
71 EXPECT_LE(exp(1.0), exp(1.0000000000000002)); 80 EXPECT_LE(exp(1.0), exp(1.0000000000000002));
72 EXPECT_EQ(2.7182818284590455, exp(1.0)); 81 EXPECT_EQ(2.7182818284590455, exp(1.0));
73 EXPECT_EQ(7.38905609893065e0, exp(2.0)); 82 EXPECT_EQ(7.38905609893065e0, exp(2.0));
74 EXPECT_EQ(1.7976931348622732e308, exp(7.09782712893383973096e+02)); 83 EXPECT_EQ(1.7976931348622732e308, exp(7.09782712893383973096e+02));
75 EXPECT_EQ(2.6881171418161356e+43, exp(100.0)); 84 EXPECT_EQ(2.6881171418161356e+43, exp(100.0));
76 EXPECT_EQ(8.218407461554972e+307, exp(709.0)); 85 EXPECT_EQ(8.218407461554972e+307, exp(709.0));
77 EXPECT_EQ(1.7968190737295725e308, exp(709.7822265625e0)); 86 EXPECT_EQ(1.7968190737295725e308, exp(709.7822265625e0));
78 EXPECT_EQ(std::numeric_limits<double>::infinity(), exp(709.7827128933841e0)); 87 EXPECT_EQ(std::numeric_limits<double>::infinity(), exp(709.7827128933841e0));
79 EXPECT_EQ(std::numeric_limits<double>::infinity(), exp(710.0)); 88 EXPECT_EQ(std::numeric_limits<double>::infinity(), exp(710.0));
80 EXPECT_EQ(std::numeric_limits<double>::infinity(), exp(1000.0)); 89 EXPECT_EQ(std::numeric_limits<double>::infinity(), exp(1000.0));
81 EXPECT_EQ(std::numeric_limits<double>::infinity(), 90 EXPECT_EQ(std::numeric_limits<double>::infinity(),
82 exp(std::numeric_limits<double>::infinity())); 91 exp(std::numeric_limits<double>::infinity()));
83 } 92 }
84 93
94 TEST(Ieee754, Expm1) {
95 EXPECT_THAT(expm1(std::numeric_limits<double>::quiet_NaN()), IsNaN());
96 EXPECT_THAT(expm1(std::numeric_limits<double>::signaling_NaN()), IsNaN());
97 EXPECT_EQ(-1.0, expm1(-std::numeric_limits<double>::infinity()));
98 EXPECT_EQ(std::numeric_limits<double>::infinity(),
99 expm1(std::numeric_limits<double>::infinity()));
100 EXPECT_EQ(0.0, expm1(-0.0));
101 EXPECT_EQ(0.0, expm1(0.0));
102 EXPECT_EQ(1.718281828459045, expm1(1.0));
103 EXPECT_EQ(2.6881171418161356e+43, expm1(100.0));
104 EXPECT_EQ(8.218407461554972e+307, expm1(709.0));
105 EXPECT_EQ(std::numeric_limits<double>::infinity(), expm1(710.0));
106 }
107
85 TEST(Ieee754, Log) { 108 TEST(Ieee754, Log) {
86 EXPECT_THAT(log(std::numeric_limits<double>::quiet_NaN()), IsNaN()); 109 EXPECT_THAT(log(std::numeric_limits<double>::quiet_NaN()), IsNaN());
87 EXPECT_THAT(log(std::numeric_limits<double>::signaling_NaN()), IsNaN()); 110 EXPECT_THAT(log(std::numeric_limits<double>::signaling_NaN()), IsNaN());
88 EXPECT_THAT(log(-std::numeric_limits<double>::infinity()), IsNaN()); 111 EXPECT_THAT(log(-std::numeric_limits<double>::infinity()), IsNaN());
89 EXPECT_THAT(log(-1.0), IsNaN()); 112 EXPECT_THAT(log(-1.0), IsNaN());
90 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(-0.0)); 113 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(-0.0));
91 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(0.0)); 114 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log(0.0));
92 EXPECT_EQ(0.0, log(1.0)); 115 EXPECT_EQ(0.0, log(1.0));
93 EXPECT_EQ(std::numeric_limits<double>::infinity(), 116 EXPECT_EQ(std::numeric_limits<double>::infinity(),
94 log(std::numeric_limits<double>::infinity())); 117 log(std::numeric_limits<double>::infinity()));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log10(-0.0)); 162 EXPECT_EQ(-std::numeric_limits<double>::infinity(), log10(-0.0));
140 EXPECT_EQ(std::numeric_limits<double>::infinity(), 163 EXPECT_EQ(std::numeric_limits<double>::infinity(),
141 log10(std::numeric_limits<double>::infinity())); 164 log10(std::numeric_limits<double>::infinity()));
142 EXPECT_EQ(3.0, log10(1000.0)); 165 EXPECT_EQ(3.0, log10(1000.0));
143 EXPECT_EQ(14.0, log10(100000000000000)); // log10(10 ^ 14) 166 EXPECT_EQ(14.0, log10(100000000000000)); // log10(10 ^ 14)
144 EXPECT_EQ(3.7389561269540406, log10(5482.2158)); 167 EXPECT_EQ(3.7389561269540406, log10(5482.2158));
145 EXPECT_EQ(14.661551142893833, log10(458723662312872.125782332587)); 168 EXPECT_EQ(14.661551142893833, log10(458723662312872.125782332587));
146 EXPECT_EQ(-0.9083828622192334, log10(0.12348583358871)); 169 EXPECT_EQ(-0.9083828622192334, log10(0.12348583358871));
147 } 170 }
148 171
172 TEST(Ieee754, cbrt) {
173 EXPECT_THAT(cbrt(std::numeric_limits<double>::quiet_NaN()), IsNaN());
174 EXPECT_THAT(cbrt(std::numeric_limits<double>::signaling_NaN()), IsNaN());
175 EXPECT_EQ(std::numeric_limits<double>::infinity(),
176 cbrt(std::numeric_limits<double>::infinity()));
177 EXPECT_EQ(-std::numeric_limits<double>::infinity(),
178 cbrt(-std::numeric_limits<double>::infinity()));
179 EXPECT_EQ(1.4422495703074083, cbrt(3));
180 EXPECT_EQ(100, cbrt(100 * 100 * 100));
181 EXPECT_EQ(46.415888336127786, cbrt(100000));
182 }
183
149 } // namespace ieee754 184 } // namespace ieee754
150 } // namespace base 185 } // namespace base
151 } // namespace v8 186 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-machops.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698