Skip to content

Commit a5bdf8a

Browse files
authored
Mention that receive/1 and ExUnit.Assertions.assert_receive/4 consumes/removes messages (#14743)
1 parent bedb677 commit a5bdf8a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/elixir/lib/kernel/special_forms.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ defmodule Kernel.SpecialForms do
23552355
defmacro try(args), do: error!([args])
23562356

23572357
@doc """
2358-
Checks if there is a message matching any of the given clauses in the current
2358+
Consumes the first message matching any of the given clauses in the current
23592359
process mailbox.
23602360
23612361
If there is no matching message, the current process waits until a matching

lib/ex_unit/lib/ex_unit/assertions.ex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,10 @@ defmodule ExUnit.Assertions do
459459
The default timeout duration is determined by the `assert_receive_timeout` option,
460460
which can be set using `ExUnit.configure/1`. This option defaults to 100 milliseconds.
461461
462-
The `pattern` argument must be a match pattern. Flunks with `failure_message`
463-
if a message matching `pattern` is not received.
462+
The `pattern` argument must be a match pattern.
463+
464+
Flunks with `failure_message` if a message matching `pattern` is not received.
465+
If a message matches, it is also removed from the process mailbox.
464466
465467
## Examples
466468
@@ -487,8 +489,10 @@ defmodule ExUnit.Assertions do
487489
Asserts that a message matching `pattern` was received and is in the
488490
current process' mailbox.
489491
490-
The `pattern` argument must be a match pattern. Flunks with `failure_message`
491-
if a message matching `pattern` was not received.
492+
The `pattern` argument must be a match pattern.
493+
494+
Flunks with `failure_message` if a message matching `pattern` was not received.
495+
If a message matches, it is also removed from the process mailbox.
492496
493497
Timeout is set to `0`, so there is no waiting time.
494498

0 commit comments

Comments
 (0)