19 #if FOLLY_HAS_COROUTINES 31 TEST(InlineTask, CallVoidTaskWithoutAwaitingNeverRuns) {
32 bool hasStarted =
false;
33 auto f = [&]() -> InlineTask<void> {
44 TEST(InlineTask, CallValueTaskWithoutAwaitingNeverRuns) {
45 bool hasStarted =
false;
46 auto f = [&]() -> InlineTask<int> {
57 TEST(InlineTask, CallRefTaskWithoutAwaitingNeverRuns) {
58 bool hasStarted =
false;
60 auto f = [&]() -> InlineTask<int&> {
71 TEST(InlineTask, SimpleVoidTask) {
73 auto f = [&]() -> InlineTask<void> {
83 TEST(InlineTask, SimpleValueTask) {
85 auto f = [&]() -> InlineTask<int> {
95 TEST(InlineTask, SimpleRefTask) {
97 auto f = [&]() -> InlineTask<bool&> {
109 struct MoveOnlyType {
114 MoveOnlyType(MoveOnlyType&& other)
noexcept 117 MoveOnlyType& operator=(MoveOnlyType&& other)
noexcept {
127 struct TypeWithImplicitSingleValueConstructor {
129 TypeWithImplicitSingleValueConstructor(
float x) : value_(x) {}
132 TEST(InlineTask, ReturnValueWithInitializerListSyntax) {
133 auto f = []() -> InlineTask<TypeWithImplicitSingleValueConstructor> {
141 struct TypeWithImplicitMultiValueConstructor {
144 TypeWithImplicitMultiValueConstructor(
150 TEST(InlineTask, ReturnValueWithInitializerListSyntax2) {
151 auto f = []() -> InlineTask<TypeWithImplicitMultiValueConstructor> {
155 co_return{
"hello", 3.1415f};
157 co_return TypeWithImplicitMultiValueConstructor{
"hello", 3.1415f};
166 TEST(InlineTask, TaskOfMoveOnlyType) {
167 auto f = []() -> InlineTask<MoveOnlyType> { co_return MoveOnlyType{42}; };
172 bool executed =
false;
173 auto g = [&]() -> InlineTask<void> {
174 auto result = co_await
f();
184 TEST(InlineTask, MoveOnlyTypeNRVO) {
185 auto f = []() -> InlineTask<MoveOnlyType> {
197 TEST(InlineTask, ReturnLvalueReference) {
199 auto f = [&]() -> InlineTask<int&> { co_return
value; };
207 TEST(InlineTask, ExceptionsPropagateFromVoidTask) {
208 auto f = []() -> InlineTask<void> {
215 TEST(InlineTask, ExceptionsPropagateFromValueTask) {
216 auto f = []() -> InlineTask<int> {
223 TEST(InlineTask, ExceptionsPropagateFromRefTask) {
224 auto f = []() -> InlineTask<int&> {
231 struct ThrowingCopyConstructor {
234 [[noreturn]] ThrowingCopyConstructor(
const ThrowingCopyConstructor&)
noexcept(
239 ThrowingCopyConstructor& operator=(
const ThrowingCopyConstructor&) =
delete;
242 TEST(InlineTask, ExceptionsPropagateFromReturnValueConstructor) {
243 auto f = []() -> InlineTask<ThrowingCopyConstructor> { co_return{}; };
247 InlineTask<void> recursiveTask(
int depth) {
249 co_await recursiveTask(depth - 1);
253 TEST(InlineTask, DeepRecursionDoesntStackOverflow) {
257 InlineTask<int> recursiveValueTask(
int depth) {
259 co_return co_await recursiveValueTask(depth - 1) + 1;
264 TEST(InlineTask, DeepRecursionOfValueTaskDoesntStackOverflow) {
268 InlineTask<void> recursiveThrowingTask(
int depth) {
270 co_await recursiveThrowingTask(depth - 1);
276 TEST(InlineTask, DeepRecursionOfExceptions) {
#define TEST(test_case_name, test_name)
#define EXPECT_THROW(statement, expected_exception)
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
requires E e noexcept(noexcept(s.error(std::move(e))))
static const char *const value
#define EXPECT_TRUE(condition)
T exchange(T &obj, U &&new_value)
#define EXPECT_FALSE(condition)
auto blockingWait(Awaitable &&awaitable) -> detail::decay_rvalue_reference_t< await_result_t< Awaitable >>