#include "src/base/ieee754.h"
#include <limits>
#include "src/base/overflowing-math.h"
#include "testing/gmock-support.h"
BitEq;
IsNaN;
namespace v8 {
namespace base {
namespace ieee754 {
namespace {
double const kE = …;
double const kPI = …;
double const kTwo120 = …;
double const kInfinity = …;
double const kQNaN = …;
double const kSNaN = …;
}
TEST(Ieee754, Acos) { … }
TEST(Ieee754, Acosh) { … }
TEST(Ieee754, Asin) { … }
TEST(Ieee754, Asinh) { … }
TEST(Ieee754, Atan) { … }
TEST(Ieee754, Atan2) { … }
TEST(Ieee754, Atanh) { … }
#if defined(V8_USE_LIBM_TRIG_FUNCTIONS)
TEST(Ieee754, LibmCos) { … }
TEST(Ieee754, LibmSin) { … }
TEST(Ieee754, FdlibmCos) { … }
TEST(Ieee754, FdlibmSin) { … }
#else
TEST(Ieee754, Cos) {
EXPECT_THAT(cos(kQNaN), IsNaN());
EXPECT_THAT(cos(kSNaN), IsNaN());
EXPECT_THAT(cos(kInfinity), IsNaN());
EXPECT_THAT(cos(-kInfinity), IsNaN());
EXPECT_EQ(1.0, 1 / cos(-0.0));
EXPECT_EQ(1.0, 1 / cos(0.0));
EXPECT_EQ(1, cos(2.3283064365386963e-10));
EXPECT_EQ(1, cos(-2.3283064365386963e-10));
EXPECT_EQ(0.9876883405951378, cos(0.15707963267948966));
EXPECT_EQ(0.7100335477927638, cos(0.7812504768371582));
EXPECT_EQ(0.7100338835660797, cos(0.78125));
EXPECT_EQ(0.9238795325112867, cos(0.39269908169872414));
EXPECT_EQ(0.9238795325112867, cos(-0.39269908169872414));
EXPECT_EQ(1, cos(3.725290298461914e-9));
EXPECT_EQ(0.9689124217106447, cos(0.25));
EXPECT_EQ(0.8775825618903728, cos(0.5));
EXPECT_EQ(0.7073882691671998, cos(0.785));
EXPECT_EQ(6.123233995736766e-17, cos(1.5707963267948966));
EXPECT_EQ(0.7071067811865474, cos(7.0 / 4 * kPI));
EXPECT_EQ(0.7071067811865477, cos(9.0 / 4 * kPI));
EXPECT_EQ(-0.7071067811865467, cos(11.0 / 4 * kPI));
EXPECT_EQ(-0.7071067811865471, cos(13.0 / 4 * kPI));
EXPECT_EQ(0.9367521275331447, cos(1000000.0));
EXPECT_EQ(-3.435757038074824e-12, cos(1048575.0 / 2 * kPI));
EXPECT_EQ(-0.9258790228548379e0, cos(kTwo120));
EXPECT_EQ(-0.9258790228548379e0, cos(-kTwo120));
}
TEST(Ieee754, Sin) {
EXPECT_THAT(sin(kQNaN), IsNaN());
EXPECT_THAT(sin(kSNaN), IsNaN());
EXPECT_THAT(sin(kInfinity), IsNaN());
EXPECT_THAT(sin(-kInfinity), IsNaN());
EXPECT_EQ(-kInfinity, Divide(1.0, sin(-0.0)));
EXPECT_EQ(kInfinity, Divide(1.0, sin(0.0)));
EXPECT_EQ(2.3283064365386963e-10, sin(2.3283064365386963e-10));
EXPECT_EQ(-2.3283064365386963e-10, sin(-2.3283064365386963e-10));
EXPECT_EQ(0.3826834323650898, sin(0.39269908169872414));
EXPECT_EQ(-0.3826834323650898, sin(-0.39269908169872414));
EXPECT_EQ(0.479425538604203, sin(0.5));
EXPECT_EQ(-0.479425538604203, sin(-0.5));
EXPECT_EQ(1, sin(kPI / 2.0));
EXPECT_EQ(-1, sin(-kPI / 2.0));
EXPECT_EQ(1.2246467991473532e-16, sin(kPI));
EXPECT_EQ(-7.047032979958965e-14, sin(2200.0 * kPI));
EXPECT_EQ(-0.7071067811865477, sin(7.0 / 4.0 * kPI));
EXPECT_EQ(0.7071067811865474, sin(9.0 / 4.0 * kPI));
EXPECT_EQ(0.7071067811865483, sin(11.0 / 4.0 * kPI));
EXPECT_EQ(-0.7071067811865479, sin(13.0 / 4.0 * kPI));
EXPECT_EQ(-3.2103381051568376e-11, sin(1048576.0 / 4 * kPI));
EXPECT_EQ(0.377820109360752e0, sin(kTwo120));
EXPECT_EQ(-0.377820109360752e0, sin(-kTwo120));
}
#endif
TEST(Ieee754, Cosh) { … }
TEST(Ieee754, Exp) { … }
TEST(Ieee754, Expm1) { … }
TEST(Ieee754, Log) { … }
TEST(Ieee754, Log1p) { … }
TEST(Ieee754, Log2) { … }
TEST(Ieee754, Log10) { … }
TEST(Ieee754, Cbrt) { … }
TEST(Ieee754, Sinh) { … }
TEST(Ieee754, Tan) { … }
TEST(Ieee754, Tanh) { … }
}
}
}