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

Unified Diff: test/unittests/base/functional-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 | « src/compiler/common-operator.cc ('k') | test/unittests/compiler/common-operator-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/base/functional-unittest.cc
diff --git a/test/unittests/base/functional-unittest.cc b/test/unittests/base/functional-unittest.cc
index d15aa5df042c8f9c403cdda1217f69438d897c7b..97a27a438e8fa3a0804edaa102a79ab9adb07376 100644
--- a/test/unittests/base/functional-unittest.cc
+++ b/test/unittests/base/functional-unittest.cc
@@ -97,6 +97,39 @@ TYPED_TEST(FunctionalTest, HashIsOkish) {
}
+TYPED_TEST(FunctionalTest, HashValueArrayUsesHashRange) {
+ TypeParam values[128];
+ this->rng()->NextBytes(&values, sizeof(values));
+ EXPECT_EQ(hash_range(values, values + arraysize(values)), hash_value(values));
+}
+
+
+TYPED_TEST(FunctionalTest, BitEqualTo) {
+ bit_equal_to<TypeParam> pred;
+ for (size_t i = 0; i < 128; ++i) {
+ TypeParam v1, v2;
+ this->rng()->NextBytes(&v1, sizeof(v1));
+ this->rng()->NextBytes(&v2, sizeof(v2));
+ EXPECT_PRED2(pred, v1, v1);
+ EXPECT_PRED2(pred, v2, v2);
+ EXPECT_EQ(memcmp(&v1, &v2, sizeof(TypeParam)) == 0, pred(v1, v2));
+ }
+}
+
+
+TYPED_TEST(FunctionalTest, BitEqualToImpliesSameBitHash) {
+ bit_hash<TypeParam> h;
+ bit_equal_to<TypeParam> e;
+ TypeParam values[32];
+ this->rng()->NextBytes(&values, sizeof(values));
+ TRACED_FOREACH(TypeParam, v1, values) {
+ TRACED_FOREACH(TypeParam, v2, values) {
+ if (e(v1, v2)) EXPECT_EQ(h(v1), h(v2));
+ }
+ }
+}
+
+
namespace {
struct Foo {
@@ -125,5 +158,39 @@ TEST(FunctionalTest, HashUsesArgumentDependentLookup) {
}
}
+
+TEST(FunctionalTest, BitEqualToFloat) {
+ bit_equal_to<float> pred;
+ EXPECT_FALSE(pred(0.0f, -0.0f));
+ EXPECT_FALSE(pred(-0.0f, 0.0f));
+ float const qNaN = std::numeric_limits<float>::quiet_NaN();
+ float const sNaN = std::numeric_limits<float>::signaling_NaN();
+ EXPECT_PRED2(pred, qNaN, qNaN);
+ EXPECT_PRED2(pred, sNaN, sNaN);
+}
+
+
+TEST(FunctionalTest, BitHashFloatDifferentForZeroAndMinusZero) {
+ bit_hash<float> h;
+ EXPECT_NE(h(0.0f), h(-0.0f));
+}
+
+
+TEST(FunctionalTest, BitEqualToDouble) {
+ bit_equal_to<double> pred;
+ EXPECT_FALSE(pred(0.0, -0.0));
+ EXPECT_FALSE(pred(-0.0, 0.0));
+ double const qNaN = std::numeric_limits<double>::quiet_NaN();
+ double const sNaN = std::numeric_limits<double>::signaling_NaN();
+ EXPECT_PRED2(pred, qNaN, qNaN);
+ EXPECT_PRED2(pred, sNaN, sNaN);
+}
+
+
+TEST(FunctionalTest, BitHashDoubleDifferentForZeroAndMinusZero) {
+ bit_hash<double> h;
+ EXPECT_NE(h(0.0), h(-0.0));
+}
+
} // namespace base
} // namespace v8
« no previous file with comments | « src/compiler/common-operator.cc ('k') | test/unittests/compiler/common-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698