A diff implementation for Elm.
This is a fork of jinjor/elm-diff, adding the possibility of considering two items similar.
This library implements Wu's O(NP) algorithm. It shares the idea with Myers's O(ND) algorithm, but is much faster in some cases.
BSD-3-Clause
Diff.diffLinesWith with elm-testYou can use this function to pretty print differences when comparing Strings in elm-test.
expectEqualMultiline : String -> String -> Expect.Expectation
expectEqualMultiline exp actual =
if exp == actual then
Expect.pass
else
let
header : String
header =
Ansi.Color.fontColor Ansi.Color.blue "Diff from expected to actual:"
in
Expect.fail
(header
++ "\n"
++ (Diff.diffLinesWith
(Diff.defaultOptions
|> Diff.ignoreLeadingWhitespace
)
exp
actual
|> Diff.ToString.diffToString { context = 4, color = True }
)
)