Then in failure message would be no output from process mailbox which in 
future will show diff with expected message 
https://github.com/elixir-lang/elixir/pull/8440

четверг, 6 декабря 2018 г., 19:46:27 UTC+3 пользователь Fernando Tapia Rico 
написал:
>
> I think you could use the "failure_message" argument for that:
>
> for times <- 0..2, do: assert_receive({"msg", _}, 100, "message received 
> only #{times}, expected 3")
>
>
> On Thursday, December 6, 2018 at 4:24:55 PM UTC+1, Anastasiya Dyachenko 
> wrote:
>>
>> Looks nice, but if there will be an error, then line number in error 
>> message will say nothing. 
>> But if it would be native function, then it might have special error 
>> message, like
>> "Message ... received only 2 times, expected 3"
>>
>> четверг, 6 декабря 2018 г., 16:31:57 UTC+3 пользователь Sven Gehring 
>> написал:
>>>
>>> Hi,
>>>
>>> Assuming you want to receive the same message, wouldn't this only be 
>>> slightly shorter than using
>>> ```
>>> for _ <- 1..3, do: assert_receive({"msg", _})
>>> ```
>>>
>>> - Sven
>>>
>>> On Thu, 6 Dec 2018 at 14:25 Anastasiya Dyachenko <[email protected]> 
>>> wrote:
>>>
>>>> Hi,
>>>> In tests often face with need to write code like
>>>> ```
>>>> assert_receive {"msg", _}
>>>> assert_receive {"msg", _}
>>>> assert_receive {"msg", _}
>>>> ```
>>>> where same messages or same matching messages expected to receive 
>>>> multiple times.
>>>> It would be match better to have ability to set number of times message 
>>>> must be received, like
>>>>
>>>> ```
>>>> assert_receive {"msg", _}, 5_000, "message", 3
>>>> ```
>>>> or
>>>> ```
>>>> assert_receive {"msg", _}, times: 3, timeout: 5_000, message: "message"
>>>> ```
>>>>
>>>> Thanks
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "elixir-lang-core" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/elixir-lang-core/1ab2968a-9a6c-444f-b9e2-ab164c9673ad%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/elixir-lang-core/1ab2968a-9a6c-444f-b9e2-ab164c9673ad%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/90bbd027-56e9-4494-b5a2-d14242445fdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to