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

Unified Diff: test/unittests/base/ieee754-unittest.cc

Issue 2086663004: [ieee754] Slightly improve unittests for exp/log. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/base/ieee754-unittest.cc
diff --git a/test/unittests/base/ieee754-unittest.cc b/test/unittests/base/ieee754-unittest.cc
index 23cf27912e1e40bfb13431779675743efa51e594..8c71b579ed9facdc4a835602a0b0087f37e2eea8 100644
--- a/test/unittests/base/ieee754-unittest.cc
+++ b/test/unittests/base/ieee754-unittest.cc
@@ -18,6 +18,7 @@ namespace ieee754 {
namespace {
+double const kE = 2.718281828459045;
double const kPI = 3.141592653589793;
double const kTwo120 = 1.329227995784916e+36;
@@ -129,9 +130,14 @@ TEST(Ieee754, Exp) {
EXPECT_EQ(1.0, exp(-0.0));
EXPECT_EQ(1.0, exp(0.0));
EXPECT_EQ(1.0, exp(2.2250738585072014e-308));
+
+ // Test that exp(x) is monotonic near 1.
EXPECT_GE(exp(1.0), exp(0.9999999999999999));
EXPECT_LE(exp(1.0), exp(1.0000000000000002));
- EXPECT_EQ(2.718281828459045, exp(1.0));
+
+ // Test that we produce the correctly rounded result for 1.
+ EXPECT_EQ(kE, exp(1.0));
+
EXPECT_EQ(7.38905609893065e0, exp(2.0));
EXPECT_EQ(1.7976931348622732e308, exp(7.09782712893383973096e+02));
EXPECT_EQ(2.6881171418161356e+43, exp(100.0));
@@ -168,6 +174,9 @@ TEST(Ieee754, Log) {
EXPECT_EQ(0.0, log(1.0));
EXPECT_EQ(std::numeric_limits<double>::infinity(),
log(std::numeric_limits<double>::infinity()));
+
+ // Test that log(E) produces the correctly rounded result.
+ EXPECT_EQ(1.0, log(kE));
}
TEST(Ieee754, Log1p) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698