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

Unified Diff: testing/gmock-support.h

Issue 831203003: [turbofan] Fix incorrect minus zero handling in the unit tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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/compiler/simplified-operator-reducer-unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/gmock-support.h
diff --git a/testing/gmock-support.h b/testing/gmock-support.h
index 44348b60e0e98bfe56c639f71f70fb1f5e114472..ad39e9269bb24404a7a9c52fd39f2479c2567f64 100644
--- a/testing/gmock-support.h
+++ b/testing/gmock-support.h
@@ -5,6 +5,8 @@
#ifndef V8_TESTING_GMOCK_SUPPORT_H_
#define V8_TESTING_GMOCK_SUPPORT_H_
+#include <cstring>
+
#include "testing/gmock/include/gmock/gmock.h"
namespace testing {
@@ -31,6 +33,25 @@ class Capture {
namespace internal {
+struct AnyBitEq {
+ template <typename A, typename B>
+ bool operator()(A const& a, B const& b) const {
+ if (sizeof(A) != sizeof(B)) return false;
+ return std::memcmp(&a, &b, sizeof(A)) == 0;
+ }
+};
+
+
+template <typename Rhs>
+class BitEqMatcher : public ComparisonBase<BitEqMatcher<Rhs>, Rhs, AnyBitEq> {
+ public:
+ explicit BitEqMatcher(Rhs const& rhs)
+ : ComparisonBase<BitEqMatcher<Rhs>, Rhs, AnyBitEq>(rhs) {}
+ static const char* Desc() { return "is bitwise equal to"; }
+ static const char* NegatedDesc() { return "isn't bitwise equal to"; }
+};
+
+
template <typename T>
class CaptureEqMatcher : public MatcherInterface<T> {
public:
@@ -60,10 +81,18 @@ class CaptureEqMatcher : public MatcherInterface<T> {
} // namespace internal
+// Creates a polymorphic matcher that matches anything whose bit representation
+// is equal to that of x.
+template <typename T>
+inline internal::BitEqMatcher<T> BitEq(T const& x) {
+ return internal::BitEqMatcher<T>(x);
+}
+
+
// CaptureEq(capture) captures the value passed in during matching as long as it
// is unset, and once set, compares the value for equality with the argument.
template <typename T>
-Matcher<T> CaptureEq(Capture<T>* capture) {
+inline Matcher<T> CaptureEq(Capture<T>* capture) {
return MakeMatcher(new internal::CaptureEqMatcher<T>(capture));
}
« no previous file with comments | « test/unittests/compiler/simplified-operator-reducer-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698