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

Unified Diff: test/unittests/compiler/common-operator-unittest.cc

Issue 636953002: [turbofan] Fix HashCode/Equals for floating point operators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address offline comments. Created 6 years, 2 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 | « test/unittests/base/functional-unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/common-operator-unittest.cc
diff --git a/test/unittests/compiler/common-operator-unittest.cc b/test/unittests/compiler/common-operator-unittest.cc
index 2cb4d19fe259f5eb26a551dcb07769c8099f838d..9fe3948c0b6820ec1d3c8a1667ec8d13b765dc52 100644
--- a/test/unittests/compiler/common-operator-unittest.cc
+++ b/test/unittests/compiler/common-operator-unittest.cc
@@ -133,23 +133,93 @@ class CommonOperatorTest : public TestWithZone {
const int kArguments[] = {1, 5, 6, 42, 100, 10000, kMaxInt};
-const float kFloat32Values[] = {
- std::numeric_limits<float>::min(), -1.0f, -0.0f, 0.0f, 1.0f,
- std::numeric_limits<float>::max()};
+
+const float kFloatValues[] = {-std::numeric_limits<float>::infinity(),
+ std::numeric_limits<float>::min(),
+ -1.0f,
+ -0.0f,
+ 0.0f,
+ 1.0f,
+ std::numeric_limits<float>::max(),
+ std::numeric_limits<float>::infinity(),
+ std::numeric_limits<float>::quiet_NaN(),
+ std::numeric_limits<float>::signaling_NaN()};
+
+
+const double kDoubleValues[] = {-std::numeric_limits<double>::infinity(),
+ std::numeric_limits<double>::min(),
+ -1.0,
+ -0.0,
+ 0.0,
+ 1.0,
+ std::numeric_limits<double>::max(),
+ std::numeric_limits<double>::infinity(),
+ std::numeric_limits<double>::quiet_NaN(),
+ std::numeric_limits<double>::signaling_NaN()};
} // namespace
TEST_F(CommonOperatorTest, Float32Constant) {
- TRACED_FOREACH(float, value, kFloat32Values) {
+ TRACED_FOREACH(float, value, kFloatValues) {
const Operator* op = common()->Float32Constant(value);
- EXPECT_FLOAT_EQ(value, OpParameter<float>(op));
+ EXPECT_PRED2(base::bit_equal_to<float>(), value, OpParameter<float>(op));
+ EXPECT_EQ(0, OperatorProperties::GetValueInputCount(op));
+ EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op));
+ EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
+ EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op));
+ EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op));
+ }
+ TRACED_FOREACH(float, v1, kFloatValues) {
+ TRACED_FOREACH(float, v2, kFloatValues) {
+ const Operator* op1 = common()->Float32Constant(v1);
+ const Operator* op2 = common()->Float32Constant(v2);
+ EXPECT_EQ(bit_cast<uint32_t>(v1) == bit_cast<uint32_t>(v2),
+ op1->Equals(op2));
+ }
+ }
+}
+
+
+TEST_F(CommonOperatorTest, Float64Constant) {
+ TRACED_FOREACH(double, value, kFloatValues) {
+ const Operator* op = common()->Float64Constant(value);
+ EXPECT_PRED2(base::bit_equal_to<double>(), value, OpParameter<double>(op));
EXPECT_EQ(0, OperatorProperties::GetValueInputCount(op));
EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op));
EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op));
EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op));
}
+ TRACED_FOREACH(double, v1, kFloatValues) {
+ TRACED_FOREACH(double, v2, kFloatValues) {
+ const Operator* op1 = common()->Float64Constant(v1);
+ const Operator* op2 = common()->Float64Constant(v2);
+ EXPECT_EQ(bit_cast<uint64_t>(v1) == bit_cast<uint64_t>(v2),
+ op1->Equals(op2));
+ }
+ }
+}
+
+
+TEST_F(CommonOperatorTest, NumberConstant) {
+ TRACED_FOREACH(double, value, kFloatValues) {
+ const Operator* op = common()->NumberConstant(value);
+ EXPECT_PRED2(base::bit_equal_to<double>(), value, OpParameter<double>(op));
+ EXPECT_EQ(0, OperatorProperties::GetValueInputCount(op));
+ EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op));
+ EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
+ EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op));
+ EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op));
+ }
+ TRACED_FOREACH(double, v1, kFloatValues) {
+ TRACED_FOREACH(double, v2, kFloatValues) {
+ const Operator* op1 = common()->NumberConstant(v1);
+ const Operator* op2 = common()->NumberConstant(v2);
+ EXPECT_EQ(bit_cast<uint64_t>(v1) == bit_cast<uint64_t>(v2),
+ op1->Equals(op2));
+ }
+ }
}
« no previous file with comments | « test/unittests/base/functional-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698