2 {-# LANGUAGE ExistentialQuantification #-}
4 {-# LANGUAGE RankNTypes #-}
9 import Symantic.Classes (ProductFunctor (..), SumFunctor (..))
10 import System.IO.Unsafe (unsafePerformIO)
12 import Test.Tasty.Golden
13 import Text.Printf (printf)
15 import Examples.Ex01 qualified as Ex01
24 [ testGroup "Layouter" $
25 (\f -> zipWith f goldens [1 :: Int ..]) $ \(Golden site) siteNum ->
26 let siteDir = printf "Site%03d" siteNum
27 in let expectedFile = getGoldenDir $ printf "Layouter/%s/expected.txt" siteDir
33 return $ fromString $ show $ layouter site
34 , testGroup "Encoder" $
35 (\f -> zipWith f goldens [1 :: Int ..]) $ \(Golden site) siteNum ->
36 let siteDir = printf "Site%03d" siteNum
37 in testGroup siteDir $
38 (\f -> zipWith f (usedRoutes site) [1 :: Int ..]) $ \inp inpNum ->
39 let expectedFile = getGoldenDir $ printf "Encoder/%s/Input%02d.expected.txt" siteDir inpNum
41 (printf "Input%02d" inpNum)
45 return $ fromString $ show $ encode site inp
48 getGoldenDir :: FilePath -> FilePath
49 getGoldenDir p = unsafePerformIO $ getDataFileName $ "tests/Goldens/" <> p
51 goldenDiff :: FilePath -> FilePath -> [String]
52 goldenDiff ref new = ["diff", "-u", "-w", "-B", ref, new]
54 data Golden = forall a. Show a => Golden (forall repr. Testable repr => repr a)
58 , Golden ("foo" </> index)
59 , Golden ("root" </> ("foo" </> index <+> "bar" </> index))
62 </> ("a" </> literalSlug "b" <+> "c" </> literalSlug "d")
63 <.> ("A" </> literalSlug "B" <+> "C" </> literalSlug "D")