Add test for delay ordering

See #2148
This commit is contained in:
Andrew Noyes 2019-09-26 12:39:57 -07:00
parent 8acce9c371
commit a2243b6501
1 changed files with 20 additions and 0 deletions

View File

@ -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<Void> f1 = map(delay(x), [last = &last](const Void&) {
*last = 1;
return Void();
});
state Future<Void> f2 = map(delay(y), [last = &last](const Void&) {
*last = 2;
return Void();
});
wait(f1 && f2);
ASSERT((x <= y) == (last == 2));
return Void();
}
template <class T, class Func, class ErrFunc, class CallbackType>
class LambdaCallback : public CallbackType, public FastAllocated<LambdaCallback<T,Func,ErrFunc,CallbackType>> {
Func func;