aboutsummaryrefslogtreecommitdiffstats
path: root/lib/eunit/include/eunit.hrl
diff options
context:
space:
mode:
authorZandra Hird <[email protected]>2015-05-20 14:18:56 +0200
committerZandra Hird <[email protected]>2015-05-20 14:18:56 +0200
commite7f6d047777f749f00820660430533aa724ae4a2 (patch)
tree4ee1a404b572a904917d72dd6bb5c8f926cea1bb /lib/eunit/include/eunit.hrl
parentfa4cb9250fb987528d650834dfeb7c96104979d0 (diff)
parente56cf8d9846e51ae88fa72c8b0992d81da6fd7d5 (diff)
downloadotp-e7f6d047777f749f00820660430533aa724ae4a2.tar.gz
otp-e7f6d047777f749f00820660430533aa724ae4a2.tar.bz2
otp-e7f6d047777f749f00820660430533aa724ae4a2.zip
Merge branch 'saleyn/eunit'
* saleyn/eunit: Add ?assertReceive(Guard, Timeout) macro to eunit OTP-12753
Diffstat (limited to 'lib/eunit/include/eunit.hrl')
-rw-r--r--lib/eunit/include/eunit.hrl20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/eunit/include/eunit.hrl b/lib/eunit/include/eunit.hrl
index 53d291430d..8a829396ec 100644
--- a/lib/eunit/include/eunit.hrl
+++ b/lib/eunit/include/eunit.hrl
@@ -166,6 +166,26 @@
%% This is mostly a convenience which gives more detailed reports.
%% Note: Guard is a guarded pattern, and can not be used for value.
-ifdef(NOASSERT).
+-define(assertReceive(Guard, Timeout), ok).
+-else.
+-define(assertReceive(Guard, Timeout),
+ begin
+ ((fun () ->
+ receive (Guard) -> ok
+ after Timeout -> erlang:error({assertReceive_timedout,
+ [{module, ?MODULE},
+ {line, ?LINE},
+ {pattern, (??Guard)},
+ {timeout, __V}]})
+ end
+ end)())
+ end).
+-endif.
+-define(_assertReceive(Guard, Timeout), ?_test(?assertReceive(Guard, Timeout))).
+
+%% This is mostly a convenience which gives more detailed reports.
+%% Note: Guard is a guarded pattern, and can not be used for value.
+-ifdef(NOASSERT).
-define(assertMatch(Guard, Expr), ok).
-else.
-define(assertMatch(Guard, Expr),