File: Diff.hs

package info (click to toggle)
haskell-xlsx 1.1.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 860 kB
  • sloc: haskell: 12,602; makefile: 6
file content (14 lines) | stat: -rw-r--r-- 580 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module Diff where

import           Data.Algorithm.Diff       (Diff (..), getGroupedDiff)
import           Data.Algorithm.DiffOutput (ppDiff)
import           Data.Monoid               ((<>))
import           Test.Tasty.HUnit          (Assertion, assertBool)
import           Text.Groom                (groom)

-- | Like '@=?' but producing a diff on failure.
(@==?) :: (Eq a, Show a) => a -> a -> Assertion
x @==? y =
    assertBool ("Expected:\n" <> groom x <> "\nDifference:\n" <> msg) (x == y)
  where
    msg = ppDiff $ getGroupedDiff (lines . groom $ x) (lines . groom $ y)