elm-explorations / elm-explorations/test
Enable test runners to produce structured diff
- Dominant language
- Elm
- Stars
- 244
- Forks
- 40
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 2
Description
Somewhere we (publicly) define the `ElmValue` custom type:
```elm
type ElmValue
= Record (List ( String, ElmValue ))
| CustomType String (List ElmValue)
| Int_ Int
| Float_ Float
| String_ String
| Char_ Char
| List_ (List ElmValue)
| Array_ (Array ElmValue)
| Dict_ (Dict ElmValue ElmValue)
| Set_ (Set ElmValue)
```
and then change the signature of `Test.Runner.Failure.Reason`
```diff
type Reason
= Custom
- | Equality String String
+ | Equality ElmValue ElmValue
| Comparison String String
- -- Expected, actual, (index of problem, expected element, actual element)
- | ListDiff (List String) (List String)
- {- I don't think we need to show the diff twice with + and - reversed. Just show it after the main vertical bar.
- "Extra" and "missing" are relative to the actual value.
- -}
- | CollectionDiff
- { expected : String
- , actual : String
- , extra : List String
- , missing : List String
- }
| TODO
| Invalid InvalidReason
```
which opens up the possibility of test runners producing structured diffs. We can provide a function
```elm
stringifyValue : ElmValue -> String
```
which a test runner could use if it did not want to rework its diff logic (we provide this function to help minimise disruptions)
---
related to #107
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.