3 # cd folly/futures/test && ruby then_compile_test.rb > ThenCompileTest.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|
49 both = "#{ret}, #{param}"
51 ["&aFunction<#{both}>"],
52 ["&SomeClass::aStaticMethod<#{both}>"],
53 ["&SomeClass::aMethod<#{both}>", "&anObject"],
54 ["aStdFunction<#{both}>()"],
55 ["[&](#{param}){return #{retval(ret)};}"],
58 [["[&](){return #{retval(ret)};}"]]
62 ).map {|a| test(a)}.flatten
65 // This file is #{"@"}generated by then_compile_test.rb. Do not edit directly.
67 #include <folly/futures/test/ThenCompileTest.h>
69 using namespace folly;
71 TEST(Basic, thenVariants) {