module Main (main) where import Datalog import Data.Text qualified as T import Data.Text.IO qualified as T import Test.Tasty import Test.Tasty.HUnit golden :: (Show err, Show val) => String -> String -> (FilePath -> IO (Either err val)) -> IO () golden outExt prefix run = do let inFile = "test/golden/" <> prefix <> ".dl" outFile = "test/golden/" <> prefix <> outExt res <- run inFile out <- T.readFile outFile case res of Left e -> assertFailure (show e) Right out' -> assertEqual "" (T.strip out) (T.pack (show out')) parserGoldenTest :: String -> TestTree parserGoldenTest prefix = testCase ("Parser test: " <> prefix) $ golden ".show" prefix readProgram {- databaseGoldenTest :: String -> TestTree databaseGoldenTest prefix = testCase ("Database test: " <> prefix) $ golden ".db0" prefix readDatabase fixedpointGoldenTest :: String -> TestTree fixedpointGoldenTest prefix = testCase ("Fixedpoint test: " <> prefix) $ golden ".dbF" prefix $ \fp -> do fmap (fmap extendFixedpointDb) (readDatabase fp) -} main :: IO () main = defaultMain $ testGroup "all" [ testGroup "parser" [ parserGoldenTest "ancestor" , parserGoldenTest "graph" ] ]