diff options
author | Fedor Indutny <fedor@indutny.com> | 2014-10-10 14:49:02 +0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-10-10 14:49:02 +0400 |
commit | 6bcea4ff932144a5fd02affefd45164fbf471e67 (patch) | |
tree | a8e078c679b12f0daebe10ed254239cb0d79e146 /deps/v8/testing | |
parent | 4fae2356d105e394115188a814097c4a95ae0c5d (diff) | |
download | android-node-v8-6bcea4ff932144a5fd02affefd45164fbf471e67.tar.gz android-node-v8-6bcea4ff932144a5fd02affefd45164fbf471e67.tar.bz2 android-node-v8-6bcea4ff932144a5fd02affefd45164fbf471e67.zip |
deps: update v8 to 3.29.93.1
Diffstat (limited to 'deps/v8/testing')
-rw-r--r-- | deps/v8/testing/gmock-support.h | 72 | ||||
-rw-r--r-- | deps/v8/testing/gmock.gyp | 9 | ||||
-rw-r--r-- | deps/v8/testing/gtest-support.h | 58 | ||||
-rw-r--r-- | deps/v8/testing/gtest-type-names.h | 34 | ||||
-rw-r--r-- | deps/v8/testing/gtest.gyp | 2 |
5 files changed, 139 insertions, 36 deletions
diff --git a/deps/v8/testing/gmock-support.h b/deps/v8/testing/gmock-support.h new file mode 100644 index 0000000000..44348b60e0 --- /dev/null +++ b/deps/v8/testing/gmock-support.h @@ -0,0 +1,72 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_TESTING_GMOCK_SUPPORT_H_ +#define V8_TESTING_GMOCK_SUPPORT_H_ + +#include "testing/gmock/include/gmock/gmock.h" + +namespace testing { + +template <typename T> +class Capture { + public: + Capture() : value_(), has_value_(false) {} + + const T& value() const { return value_; } + bool has_value() const { return has_value_; } + + void SetValue(const T& value) { + DCHECK(!has_value()); + value_ = value; + has_value_ = true; + } + + private: + T value_; + bool has_value_; +}; + + +namespace internal { + +template <typename T> +class CaptureEqMatcher : public MatcherInterface<T> { + public: + explicit CaptureEqMatcher(Capture<T>* capture) : capture_(capture) {} + + virtual void DescribeTo(std::ostream* os) const { + *os << "captured by " << static_cast<const void*>(capture_); + if (capture_->has_value()) *os << " which has value " << capture_->value(); + } + + virtual bool MatchAndExplain(T value, MatchResultListener* listener) const { + if (!capture_->has_value()) { + capture_->SetValue(value); + return true; + } + if (value != capture_->value()) { + *listener << "which is not equal to " << capture_->value(); + return false; + } + return true; + } + + private: + Capture<T>* capture_; +}; + +} // namespace internal + + +// 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) { + return MakeMatcher(new internal::CaptureEqMatcher<T>(capture)); +} + +} // namespace testing + +#endif // V8_TESTING_GMOCK_SUPPORT_H_ diff --git a/deps/v8/testing/gmock.gyp b/deps/v8/testing/gmock.gyp index a36584dcf7..ba4386141a 100644 --- a/deps/v8/testing/gmock.gyp +++ b/deps/v8/testing/gmock.gyp @@ -30,7 +30,7 @@ 'gmock/src/gmock-matchers.cc', 'gmock/src/gmock-spec-builders.cc', 'gmock/src/gmock.cc', - 'gmock_mutant.h', # gMock helpers + 'gmock-support.h', # gMock helpers ], 'sources!': [ 'gmock/src/gmock-all.cc', # Not needed by our build. @@ -47,6 +47,13 @@ 'export_dependent_settings': [ 'gtest.gyp:gtest', ], + 'conditions': [ + ['want_separate_host_toolset==1', { + 'toolsets': ['host', 'target'], + }, { + 'toolsets': ['target'], + }], + ], }, { 'target_name': 'gmock_main', diff --git a/deps/v8/testing/gtest-support.h b/deps/v8/testing/gtest-support.h new file mode 100644 index 0000000000..66b1094ff4 --- /dev/null +++ b/deps/v8/testing/gtest-support.h @@ -0,0 +1,58 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_TESTING_GTEST_SUPPORT_H_ +#define V8_TESTING_GTEST_SUPPORT_H_ + +#include "include/v8stdint.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace testing { +namespace internal { + +#define GET_TYPE_NAME(type) \ + template <> \ + inline std::string GetTypeName<type>() { \ + return #type; \ + } +GET_TYPE_NAME(int8_t) +GET_TYPE_NAME(uint8_t) +GET_TYPE_NAME(int16_t) +GET_TYPE_NAME(uint16_t) +GET_TYPE_NAME(int32_t) +GET_TYPE_NAME(uint32_t) +GET_TYPE_NAME(int64_t) +GET_TYPE_NAME(uint64_t) +GET_TYPE_NAME(float) +GET_TYPE_NAME(double) +#undef GET_TYPE_NAME + + +// TRACED_FOREACH(type, var, array) expands to a loop that assigns |var| every +// item in the |array| and adds a SCOPED_TRACE() message for the |var| while +// inside the loop body. +// TODO(bmeurer): Migrate to C++11 once we're ready. +#define TRACED_FOREACH(_type, _var, _array) \ + for (size_t _i = 0; _i < arraysize(_array); ++_i) \ + for (bool _done = false; !_done;) \ + for (_type const _var = _array[_i]; !_done;) \ + for (SCOPED_TRACE(::testing::Message() << #_var << " = " << _var); \ + !_done; _done = true) + + +// TRACED_FORRANGE(type, var, low, high) expands to a loop that assigns |var| +// every value in the range |low| to (including) |high| and adds a +// SCOPED_TRACE() message for the |var| while inside the loop body. +// TODO(bmeurer): Migrate to C++11 once we're ready. +#define TRACED_FORRANGE(_type, _var, _low, _high) \ + for (_type _i = _low; _i <= _high; ++_i) \ + for (bool _done = false; !_done;) \ + for (_type const _var = _i; !_done;) \ + for (SCOPED_TRACE(::testing::Message() << #_var << " = " << _var); \ + !_done; _done = true) + +} // namespace internal +} // namespace testing + +#endif // V8_TESTING_GTEST_SUPPORT_H_ diff --git a/deps/v8/testing/gtest-type-names.h b/deps/v8/testing/gtest-type-names.h deleted file mode 100644 index ba900ddb88..0000000000 --- a/deps/v8/testing/gtest-type-names.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_TESTING_GTEST_TYPE_NAMES_H_ -#define V8_TESTING_GTEST_TYPE_NAMES_H_ - -#include "include/v8stdint.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace testing { -namespace internal { - -#define GET_TYPE_NAME(type) \ - template <> \ - std::string GetTypeName<type>() { \ - return #type; \ - } -GET_TYPE_NAME(int8_t) -GET_TYPE_NAME(uint8_t) -GET_TYPE_NAME(int16_t) -GET_TYPE_NAME(uint16_t) -GET_TYPE_NAME(int32_t) -GET_TYPE_NAME(uint32_t) -GET_TYPE_NAME(int64_t) -GET_TYPE_NAME(uint64_t) -GET_TYPE_NAME(float) -GET_TYPE_NAME(double) -#undef GET_TYPE_NAME - -} // namespace internal -} // namespace testing - -#endif // V8_TESTING_GTEST_TYPE_NAMES_H_ diff --git a/deps/v8/testing/gtest.gyp b/deps/v8/testing/gtest.gyp index 5d068d0257..d7662101cf 100644 --- a/deps/v8/testing/gtest.gyp +++ b/deps/v8/testing/gtest.gyp @@ -37,7 +37,7 @@ 'gtest/src/gtest-test-part.cc', 'gtest/src/gtest-typed-test.cc', 'gtest/src/gtest.cc', - 'gtest-type-names.h', + 'gtest-support.h', ], 'sources!': [ 'gtest/src/gtest-all.cc', # Not needed by our build. |