1 {-# LANGUAGE ExistentialQuantification #-}
5 import Control.Monad (Monad (..))
6 import Data.Either (Either (..))
7 import Data.Function (($))
9 import Data.List qualified as List
10 import Data.Semigroup (Semigroup (..))
11 import Data.String (IsString (..), String)
12 import Symantic.Classes (ProductFunctor (..), SumFunctor (..))
13 import System.IO (FilePath)
14 import System.IO.Unsafe (unsafePerformIO)
16 import Test.Tasty.Golden
17 import Text.Printf (printf)
18 import Text.Show (Show (..))
27 [ testGroup "Encoder" $
28 (\f -> List.zipWith f goldens [1 :: Int ..]) $ \(Golden site inps) siteNum ->
29 let siteDir = printf "Site%03d" siteNum
30 in testGroup siteDir $
31 (\f -> List.zipWith f inps [1 :: Int ..]) $ \inp inpNum ->
32 let expectedFile = getGoldenDir $ printf "Encoder/%s/Input%02d.expected.txt" siteDir inpNum
34 (printf "Input%02d" inpNum)
38 return $ fromString $ show $ encode site inp
39 , testGroup "Layouter" $
40 (\f -> List.zipWith f goldens [1 :: Int ..]) $ \(Golden site _) siteNum ->
41 let siteDir = printf "Site%03d" siteNum
42 in let expectedFile = getGoldenDir $ printf "Layouter/%s/expected.txt" siteDir
48 return $ fromString $ show $ layouter site
51 getGoldenDir :: FilePath -> FilePath
52 getGoldenDir p = unsafePerformIO $ getDataFileName $ "tests/Goldens/" <> p
54 goldenDiff :: FilePath -> FilePath -> [String]
55 goldenDiff ref new = ["diff", "-u", "-w", "-B", ref, new]
57 data Golden repr = forall inp. Show inp => Golden (repr inp) [inp]
59 ProductFunctor repr =>
65 , Golden ("foo" </> index) [()]