From a2243b6501ff09a3b1fbcaae36a687baf4be78b8 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Thu, 26 Sep 2019 12:39:57 -0700 Subject: [PATCH] Add test for delay ordering See #2148 --- fdbrpc/FlowTests.actor.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fdbrpc/FlowTests.actor.cpp b/fdbrpc/FlowTests.actor.cpp index 87645975ae..7317c81ff0 100644 --- a/fdbrpc/FlowTests.actor.cpp +++ b/fdbrpc/FlowTests.actor.cpp @@ -50,6 +50,26 @@ TEST_CASE("/flow/actorcompiler/lineNumbers") { return Void(); } +TEST_CASE("/flow/delayOrdering") { + state double x = deterministicRandom()->random01(); + state double y = deterministicRandom()->random01(); + if (BUGGIFY) { + y = x; + } + state int last = 0; + state Future f1 = map(delay(x), [last = &last](const Void&) { + *last = 1; + return Void(); + }); + state Future f2 = map(delay(y), [last = &last](const Void&) { + *last = 2; + return Void(); + }); + wait(f1 && f2); + ASSERT((x <= y) == (last == 2)); + return Void(); +} + template class LambdaCallback : public CallbackType, public FastAllocated> { Func func;