1 {-# LANGUAGE AllowAmbiguousTypes #-}
3 {-# LANGUAGE ExistentialQuantification #-}
4 {-# LANGUAGE ImportQualifiedPost #-}
6 {-# LANGUAGE RankNTypes #-}
7 {-# LANGUAGE TypeApplications #-}
8 {-# OPTIONS_GHC -Wno-orphans #-}
12 import Data.List qualified as List
14 import Symantic qualified as Sym
15 import Symantic.Classes (ProductFunctor (..), SumFunctor (..))
16 import System.IO.Unsafe (unsafePerformIO)
18 import Test.Tasty.Golden
19 import Text.Printf (printf)
21 import Examples.Ex01 qualified as Ex01
22 import Examples.Ex02 qualified as Ex02
34 (printf "Site%03d" siteNum)
36 (printf "Model%02d" modelNum)
38 (getGoldenDir (printf "Generator/Site%03d/Model%02d/expected.txt" siteNum modelNum))
40 return $ fromString $ List.unlines $ show <$> generate (Sym.unReader site model)
41 | (modelNum, model) <- ol models
43 | (siteNum, Golden site models) <- ol goldens
48 (printf "Site%03d" siteNum)
50 (printf "Model%02d" modelNum)
52 (printf "Gen%03d" genNum)
54 (getGoldenDir (printf "Encoder/Site%03d/Model%02d/Gen%03d.expected.txt" siteNum modelNum genNum))
56 return $ fromString $ show $ encode (Sym.unReader site model) genValue
57 | (genNum, Gen{..}) <- ol $ generate (Sym.unReader site model)
59 | (modelNum, model) <- ol models
61 | (siteNum, Golden site models) <- ol goldens
65 getGoldenDir :: FilePath -> FilePath
66 getGoldenDir p = unsafePerformIO $ getDataFileName $ "tests/Goldens/" <> p
68 goldenDiff :: FilePath -> FilePath -> [String]
69 goldenDiff ref new = ["diff", "-u", "-w", "-B", ref, new]
77 (forall repr. Testable model repr => Sym.Reader model repr a)
82 [ Golden @() index [()]
86 , Golden @(Either () ())
87 ("root" </> ("foo" </> index <+> "bar" </> index))
89 , Golden @(Either () (), Either () ())
91 </> ("a" </> literalSlug "b" <+> "c" </> literalSlug "d")
92 <.> ("A" </> literalSlug "B" <+> "C" </> literalSlug "D")
96 , Golden @Ex01.Site Ex01.site [()]
97 , Golden @Ex02.Site Ex02.site [Ex02.model0]