proxygen
CallbackLifetimeTest.cpp File Reference
#include <folly/futures/Future.h>
#include <thread>
#include <folly/futures/test/TestExecutor.h>
#include <folly/portability/GTest.h>

Go to the source code of this file.

Functions

 TEST_F (CallbackLifetimeTest, thenReturnsValue)
 
 TEST_F (CallbackLifetimeTest, thenReturnsValueThrows)
 
 TEST_F (CallbackLifetimeTest, thenReturnsFuture)
 
 TEST_F (CallbackLifetimeTest, thenReturnsFutureThrows)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesExnReturnsValueMatch)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesExnReturnsValueMatchThrows)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesExnReturnsValueWrong)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesExnReturnsValueWrongThrows)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesExnReturnsFutureMatch)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesExnReturnsFutureMatchThrows)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesExnReturnsFutureWrong)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesExnReturnsFutureWrongThrows)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesWrapReturnsValue)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesWrapReturnsValueThrows)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesWrapReturnsFuture)
 
 TEST_F (CallbackLifetimeTest, onErrorTakesWrapReturnsFutureThrows)
 

Function Documentation

TEST_F ( CallbackLifetimeTest  ,
thenReturnsValue   
)

Definition at line 77 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

77  {
78  auto c = mkC();
79  via(&executor).thenValue([_ = mkCGuard(c)](auto&&) {}).wait();
80  EXPECT_EQ(1, *c);
81 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
thenReturnsValueThrows   
)

Definition at line 83 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

83  {
84  auto c = mkC();
85  via(&executor).thenValue([_ = mkCGuard(c)](auto&&) { raise(); }).wait();
86  EXPECT_EQ(1, *c);
87 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
thenReturnsFuture   
)

Definition at line 89 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::makeFuture(), folly::via(), and folly::detail::distributed_mutex::wait().

89  {
90  auto c = mkC();
91  via(&executor)
92  .thenValue([_ = mkCGuard(c)](auto&&) { return makeFuture(); })
93  .wait();
94  EXPECT_EQ(1, *c);
95 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition: Future-inl.h:1310
TEST_F ( CallbackLifetimeTest  ,
thenReturnsFutureThrows   
)

Definition at line 97 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

97  {
98  auto c = mkC();
99  via(&executor)
100  .thenValue([_ = mkCGuard(c)](auto&&) { return raiseFut(); })
101  .wait();
102  EXPECT_EQ(1, *c);
103 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesExnReturnsValueMatch   
)

Definition at line 105 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

105  {
106  auto c = mkC();
107  via(&executor)
108  .thenValue(raise)
109  .onError([_ = mkCGuard(c)](std::exception&) {})
110  .wait();
111  EXPECT_EQ(1, *c);
112 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesExnReturnsValueMatchThrows   
)

Definition at line 114 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

114  {
115  auto c = mkC();
116  via(&executor)
117  .thenValue(raise)
118  .onError([_ = mkCGuard(c)](std::exception&) { raise(); })
119  .wait();
120  EXPECT_EQ(1, *c);
121 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesExnReturnsValueWrong   
)

Definition at line 123 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

123  {
124  auto c = mkC();
125  via(&executor)
126  .thenValue(raise)
127  .onError([_ = mkCGuard(c)](std::logic_error&) {})
128  .wait();
129  EXPECT_EQ(1, *c);
130 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesExnReturnsValueWrongThrows   
)

Definition at line 132 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

132  {
133  auto c = mkC();
134  via(&executor)
135  .thenValue(raise)
136  .onError([_ = mkCGuard(c)](std::logic_error&) { raise(); })
137  .wait();
138  EXPECT_EQ(1, *c);
139 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesExnReturnsFutureMatch   
)

Definition at line 141 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::makeFuture(), folly::via(), and folly::detail::distributed_mutex::wait().

141  {
142  auto c = mkC();
143  via(&executor)
144  .thenValue(raise)
145  .onError([_ = mkCGuard(c)](std::exception&) { return makeFuture(); })
146  .wait();
147  EXPECT_EQ(1, *c);
148 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition: Future-inl.h:1310
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesExnReturnsFutureMatchThrows   
)

Definition at line 150 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

150  {
151  auto c = mkC();
152  via(&executor)
153  .thenValue(raise)
154  .onError([_ = mkCGuard(c)](std::exception&) { return raiseFut(); })
155  .wait();
156  EXPECT_EQ(1, *c);
157 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesExnReturnsFutureWrong   
)

Definition at line 159 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::makeFuture(), folly::via(), and folly::detail::distributed_mutex::wait().

159  {
160  auto c = mkC();
161  via(&executor)
162  .thenValue(raise)
163  .onError([_ = mkCGuard(c)](std::logic_error&) { return makeFuture(); })
164  .wait();
165  EXPECT_EQ(1, *c);
166 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition: Future-inl.h:1310
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesExnReturnsFutureWrongThrows   
)

Definition at line 168 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

168  {
169  auto c = mkC();
170  via(&executor)
171  .thenValue(raise)
172  .onError([_ = mkCGuard(c)](std::logic_error&) { return raiseFut(); })
173  .wait();
174  EXPECT_EQ(1, *c);
175 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesWrapReturnsValue   
)

Definition at line 177 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

177  {
178  auto c = mkC();
179  via(&executor)
180  .thenValue(raise)
181  .onError([_ = mkCGuard(c)](exception_wrapper&&) {})
182  .wait();
183  EXPECT_EQ(1, *c);
184 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesWrapReturnsValueThrows   
)

Definition at line 186 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

186  {
187  auto c = mkC();
188  via(&executor)
189  .thenValue(raise)
190  .onError([_ = mkCGuard(c)](exception_wrapper&&) { raise(); })
191  .wait();
192  EXPECT_EQ(1, *c);
193 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesWrapReturnsFuture   
)

Definition at line 195 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::makeFuture(), folly::via(), and folly::detail::distributed_mutex::wait().

195  {
196  auto c = mkC();
197  via(&executor)
198  .thenValue(raise)
199  .onError([_ = mkCGuard(c)](exception_wrapper&&) { return makeFuture(); })
200  .wait();
201  EXPECT_EQ(1, *c);
202 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition: Future-inl.h:1310
TEST_F ( CallbackLifetimeTest  ,
onErrorTakesWrapReturnsFutureThrows   
)

Definition at line 204 of file CallbackLifetimeTest.cpp.

References testing::_, c, folly::pushmi::executor, EXPECT_EQ, folly::via(), and folly::detail::distributed_mutex::wait().

204  {
205  auto c = mkC();
206  via(&executor)
207  .thenValue(raise)
208  .onError([_ = mkCGuard(c)](exception_wrapper&&) { return raiseFut(); })
209  .wait();
210  EXPECT_EQ(1, *c);
211 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
PUSHMI_INLINE_VAR constexpr detail::via_fn via
Definition: via.h:166
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
const internal::AnythingMatcher _
char c