Wouldn't it be more difficult to determine the right thing to print based 
on a MatchError, than the operator and operands?  Maybe not all that 
harder, but I do prefer the explicitness of saying "I'm comparing a 
subset", rather than "attempting an assignment" 

On Wednesday, October 18, 2017 at 8:03:05 AM UTC-5, Louis Pilfold wrote:
>
> Hey
>
> The `assert` macro handles MatchError as well as true/false.
>
> >  Ideally, in the assertion results, it would highlight the failing 
> key/values as well.
>
> This would be a nice addition to ExUnit. I would rather see this than any 
> addition to =~
>
> Cheers,
> Louis
>
> On Wed, 18 Oct 2017 at 13:43 <[email protected] <javascript:>> 
> wrote:
>
>> Yes, but that throws a MatchError exception if not satisfied, not a 
>> true/false.  Ideally, in the assertion results, it would highlight the 
>> failing key/values as well.  Primarily for testing, but also a quick way to 
>> test for the presence of multiple key/values in larger maps.
>>
>>
>> On Wednesday, October 18, 2017 at 12:14:00 AM UTC-5, Andrew Timberlake 
>> wrote:
>>
>>> You can do that with pattern matching,
>>>
>>> assert %{field1: "foo", field2: "bar"} = data
>>>
>>
>>> On 18 Oct 2017, 05:01 +0200, [email protected], wrote:
>>>
>> I think it would be useful if =~ supported maps.  =~ would return true if 
>>> the key/values in the right hand map were also contained in the left-hand 
>>> map.  I think this would be especially useful for testing, as you could 
>>> check that the result matched a subset of the map, rather than the whole 
>>> map. 
>>>
>>> e.g.
>>> data = Repo.insert!(src)
>>> # data = %Data{id: 25, field1: "foo", field2: "bar", inserted_at: 
>>> ~N[2017-01-01], updated_at: ~N[2017-01-01]}
>>> assert data =~ %{field1: "foo", field2: "bar"}  # true
>>>
>>> --
>>> 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/7eaabb77-6c7a-4fcb-a74a-fc303f5ace26%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/elixir-lang-core/7eaabb77-6c7a-4fcb-a74a-fc303f5ace26%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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/elixir-lang-core/fb23650e-c3f4-4694-86e1-62cdc2b9e103%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/elixir-lang-core/fb23650e-c3f4-4694-86e1-62cdc2b9e103%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/67f18c62-08e9-4e68-b8c7-e7d3e8dcf36b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to