I might be wrong but it feels like the error displayed from elm-test when an
Expect.equal fails, is a string diff of the result of running
Debug.toString on the two values being compared.
This is more than adequate for simple values but for nested mixes of records & lists it feels less helpful and sometimes quiet a strain to read in the terminal output.
I was wondering if there is a chance of using a similar approach to the
Debug.toString but instead converting to a generic data representation, perhaps something like this:
type DataType = IntData Int | FloatData Float | StringData String | TupleData (List DataType ) | ListData (List DataType) | RecordData (List ( String, DataType )) | ...
And then diffing the two results in Elm with a clearer display closer to the diff one might get from modern JS testing frameworks.
It assumes that all data is ultimately translatable to such a structure and I don’t know if that is true. You might notice I haven’t included a representation for custom types though I feel it could be possible.
I tried to experiment with the concept a little but it involves Kernel code and the changes I’ve attempted in my local clone of
elm-explorations/test result in a
Corrupt Dependency error when running the
./tests/test.sh script and I’ve no idea how to progress.
Do you think this idea has merit? I suspect that if it did it would have been tried already but I’m curious all the same.