mirror of
https://github.com/anoma/juvix.git
synced 2024-12-23 23:30:40 +03:00
[test] show diff when ast's are different
This commit is contained in:
parent
6ce6489617
commit
eedf468261
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user