then-with-Executor
[folly.git] / folly / futures / test / ViaTest.cpp
index 390787d1e3f3395f0f0e6c0548f9e265e7e3f40c..0675baf8b3570169e2b4360120613c7b570aef1a 100644 (file)
@@ -184,3 +184,36 @@ TEST(Via, chain3) {
   EXPECT_EQ(42, f.get());
   EXPECT_EQ(3, count);
 }
+
+// TODO(6838553)
+#ifndef __clang__
+TEST(Via, then2) {
+  ManualExecutor x1, x2;
+  bool a,b,c;
+  via(&x1)
+    .then([&]{ a = true; })
+    .then(&x2, [&]{ b = true; })
+    .then([&]{ c = true; });
+
+  EXPECT_FALSE(a);
+  EXPECT_FALSE(b);
+
+  x1.run();
+  EXPECT_TRUE(a);
+  EXPECT_FALSE(b);
+  EXPECT_FALSE(c);
+
+  x2.run();
+  EXPECT_TRUE(b);
+  EXPECT_FALSE(c);
+
+  x1.run();
+  EXPECT_TRUE(c);
+}
+
+TEST(Via, then2Variadic) {
+  struct Foo { void foo(Try<void>) {} };
+  Foo f;
+  makeFuture().then(nullptr, &Foo::foo, &f);
+}
+#endif