No easy way to compare lists (or other datasets) in a manner other than exact equals
As the title says, take for example the case where I would like to compare a List Float or similar case. There is no method to reduce: List Expectation -> Expectation or customListEquals: (a -> a -> Expectation) -> List a -> List a -> Expectation
@JonathanFraser can you show us some code (or pseudocode) of what you'd like to be able to do?
Specifically I was implementing some numeric code (DFT), this type of transform operates in a matrix multiplication type fashion. Moreover, it uses complex numbers so I need a custom data type to capture the pair. The type signature of the function in question is:
dft: List Complex -> List Complex
There is a corresponding inverse (idft) with the same signature and I need to validate the property
dft x |> idft == x but in the floating point sense as opposed to the exact equals sense.
I would like to be able to compare the two lists with a custom operator, something like:
complexCompare: Complex -> Complex -> Expectation
(\x ->
dft x
|> idft
|> customListCompare complexCompare x
)
or something similar that allows for the same properties testing but with a datastructure that won't obey exact equality.
It sounds to me like you want a functions of the sort existing in this module: https://github.com/NoRedInk/elm-formatted-text/blob/master/tests/EqualCheck.elm
Granted, the functions there's not a EqualCheck a -> EqualCheck (List a) in there, but it would be easy to imagine it can be added.
I've also been in the position where I felt I needed to build a custom equality function to go along with a custom type I created, for writing tests around that type. I'm not a hundred percent sure yet the approach taken in the module linked above is the best, but it might be nice to experiment with it, perhaps build a library for specifically that purpose.
I have this problem too. I have two lists and want to check that one is a subset of the other (with some slight domain-specific complexity as well). I have a predicate I can use to test the subset part, but I lack the ability to make an Expectation with the two inputs. Right now I'm doing:
if (Util.containsOrdered expected ops)
then Expect.pass
else Expect.equal expected ops
|> Expect.onFail "not equal: these should be containsOrdered"