-- | @QuickCheck@ related utilities.
module Data.TreeDiff.QuickCheck (
    ediffEq,
    ) where

import Data.TreeDiff
import System.Console.ANSI (SGR (Reset), setSGRCode)
import Test.QuickCheck     (Property, counterexample)

-- | A variant of '===', which outputs a diff when values are inequal.
ediffEq :: (Eq a, ToExpr a) => a -> a -> Property
ediffEq :: forall a. (Eq a, ToExpr a) => a -> a -> Property
ediffEq a
x a
y = forall prop. Testable prop => String -> prop -> Property
counterexample
    ([SGR] -> String
setSGRCode [SGR
Reset] forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (Edit EditExpr -> Doc
ansiWlEditExpr forall a b. (a -> b) -> a -> b
$ forall a. ToExpr a => a -> a -> Edit EditExpr
ediff a
x a
y))
    (a
x forall a. Eq a => a -> a -> Bool
== a
y)