3 # ruby thens.rb > Thens.cpp
5 # An exercise in combinatorics.
6 # (ordinary/static function, member function, std::function, lambda)
8 # returns (Future<R>, R)
10 # accepts (Try<T>&&, Try<T> const&, Try<T>, T&&, T const&, T, nothing)
13 args = args.join(", ")
15 "{Future<B> f = someFuture<A>().then(#{args});}",
16 #"{Future<B> f = makeFuture(A()).then(#{args}, anExecutor);}",
22 "Future<B>" => "someFuture<B>()",
23 "Try<B>" => "Try<B>(B())",
46 return_types.map { |ret|
47 param_types.map { |param|
48 both = "#{ret}, #{param}"
50 ["&aFunction<#{both}>"],
51 ["&SomeClass::aStaticMethod<#{both}>"],
52 # TODO switch these around (std::bind-style)
53 ["&anObject", "&SomeClass::aMethod<#{both}>"],
54 ["aStdFunction<#{both}>()"],
55 ["[&](#{param}){return #{retval(ret)};}"],
61 ).map {|a| test(a)}.flatten
64 // This file is #{"@"}generated by thens.rb. Do not edit directly.
66 // TODO: fails to compile with clang:dev. See task #4412111
69 #include <folly/wangle/futures/test/Thens.h>
71 TEST(Future, thenVariants) {
73 folly::Executor* anExecutor;