just and contains checkers have some tricky logic that normalizes the expected and actual arguments. In a specific corner case, when actual is a map and expected is a list of maps, the normalization logic tries to turn expected into a map. This can lead to loss of information due to key merging, and hence incorrect check results.
For example, the following fact erroneously passes:
(fact
{:a 2} => (just [{:a 1} {:a 2}])
; `just` will turn ` [{:a 1} {:a 2}]` into {:a 2} via `(into {} expected)`
Such merging in the context of just can never result in a true result, so my solution is to prevent such normalization, leaving expected as a list, hence causing the check to fail.
The same applies to contains because if actual is a map and expected is a list of maps, any merging means that the actual map can never contain the entries (which will have duplicates) in the expected list.
The last usage of standardized-arguments is for has-prefix, which doesn't have sensible semantics when actual is a map, so we don't need to worry about it.
Fix for https://github.com/marick/Midje/issues/348
just
andcontains
checkers have some tricky logic that normalizes theexpected
andactual
arguments. In a specific corner case, whenactual
is a map andexpected
is a list of maps, the normalization logic tries to turnexpected
into a map. This can lead to loss of information due to key merging, and hence incorrect check results.For example, the following
fact
erroneously passes:Such merging in the context of
just
can never result in atrue
result, so my solution is to prevent such normalization, leavingexpected
as a list, hence causing the check to fail.The same applies to
contains
because ifactual
is a map andexpected
is a list of maps, any merging means that theactual
map can never contain the entries (which will have duplicates) in theexpected
list.The last usage of
standardized-arguments
is forhas-prefix
, which doesn't have sensible semantics whenactual
is a map, so we don't need to worry about it.