diff --git a/package.yaml b/package.yaml index 05a7e110b..c5ffa9e69 100644 --- a/package.yaml +++ b/package.yaml @@ -50,6 +50,8 @@ dependencies: # when running the tests. Is there a better solution? - tasty - tasty-hunit +- Diff == 0.4.* +- pretty-show == 1.10.* # TODO organize this ghc-options: @@ -89,7 +91,6 @@ executables: dependencies: - minijuvix - optparse-applicative == 0.17.* - - pretty-show == 1.10.* verbatim: default-language: GHC2021 diff --git a/test/Scope/Positive.hs b/test/Scope/Positive.hs index 99cedd0b0..89e9d08ee 100644 --- a/test/Scope/Positive.hs +++ b/test/Scope/Positive.hs @@ -5,6 +5,9 @@ import qualified MiniJuvix.Syntax.Concrete.Scoped.Pretty.Text as M import qualified MiniJuvix.Syntax.Concrete.Scoped.Scoper as M import MiniJuvix.Syntax.Concrete.Scoped.Utils import qualified Data.HashMap.Strict as HashMap +import Text.Show.Pretty hiding (Html) +import Data.Algorithm.Diff +import Data.Algorithm.DiffOutput data PosTest = PosTest { @@ -44,11 +47,22 @@ testDescr PosTest {..} = TestDescr { s' <- fromRightIO' printErrorAnsi $ return (M.scopeCheck1Pure fs "." p') step "Checks" - assertBool "check: scope . parse . pretty . scope . parse = scope . parse" (s == s') - assertBool "check: parse . pretty . scope . parse = parse" (p == p') - assertBool "check: parse . pretty . parse = parse" (p == parsedPretty') + assertEqDiff "check: scope . parse . pretty . scope . parse = scope . parse" s s' + assertEqDiff "check: parse . pretty . scope . parse = parse" p p' + assertEqDiff "check: parse . pretty . parse = parse" p parsedPretty' } +assertEqDiff :: (Eq a, Show a) => String -> a -> a -> Assertion +assertEqDiff msg a b + | a == b = return () + | otherwise = do + putStrLn (pack $ ppDiff (getGroupedDiff pa pb)) + putStrLn "End diff" + fail msg + where + pa = lines $ ppShow a + pb = lines $ ppShow b + allTests :: TestTree allTests = testGroup "Scope positive tests" (map (mkTest . testDescr) tests)