Commit ccd77b85 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

Move makeAsyncTask test helpers inline into the test

Summary: [Folly] Move `makeAsyncTask` test helpers inline into the test.

Reviewed By: ericniebler

Differential Revision: D22674219

fbshipit-source-id: 630c84ce153ad2bfb92d38f3d2c955cb3f043799
parent 6edefe20
......@@ -1330,12 +1330,14 @@ TEST(Future, makePromiseContract) {
EXPECT_EQ(4, std::move(c.second).get());
}
Future<bool> call(int depth, Executor* executor) {
TEST(Future, ThenRecursion) {
struct Helpers {
static Future<bool> call(int depth, Executor* executor) {
return makeFuture().thenValueInline(
makeAsyncTask(executor, [=](auto&&) { return depth == 0; }));
}
}
Future<int> recursion(Executor* executor, int depth) {
static Future<int> recursion(Executor* executor, int depth) {
return makeFuture().thenValue([=](auto) {
return call(depth, executor).thenValue([=](auto result) {
if (result) {
......@@ -1345,12 +1347,12 @@ Future<int> recursion(Executor* executor, int depth) {
return recursion(executor, depth - 1);
});
});
}
}
};
TEST(Future, ThenRecursion) {
ManualExecutor executor;
EXPECT_EQ(42, recursion(&executor, 100000).getVia(&executor));
EXPECT_EQ(42, Helpers::recursion(&executor, 100000).getVia(&executor));
}
// We want to detect if the Try value is being dereferenced before being
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment