Merge pull request #42 from rabbitmq/await-match

Add ?awaitMatch macro
This commit is contained in:
Philip Kuryloski 2020-07-02 11:43:54 +02:00 committed by GitHub
commit 6f6d9f74bc
2 changed files with 22 additions and 2 deletions

View File

@ -0,0 +1,21 @@
-define(awaitMatch(Guard, Expr, Timeout),
begin
((fun Filter(Horizon) ->
R = Expr,
case (R) of
Guard -> R;
__V -> case erlang:system_time(millisecond) of
Now when Now < Horizon ->
timer:sleep(min(50, Horizon - Now)),
Filter(Horizon);
_ ->
erlang:error({awaitMatch,
[{module, ?MODULE},
{line, ?LINE},
{expression, (??Expr)},
{pattern, (??Guard)},
{value, __V}]})
end
end
end)(erlang:system_time(millisecond) + Timeout))
end).

View File

@ -20,8 +20,7 @@
-export([run_proper/3]).
run_proper(Fun, Args, NumTests) ->
?assertEqual(
true,
?assert(
proper:counterexample(erlang:apply(Fun, Args),
[{numtests, NumTests},
{on_output, fun(".", _) -> ok; % don't print the '.'s on new lines