1 {-# OPTIONS_GHC -Wno-missing-signatures #-}
2 {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
3 module Golden.Splice where
5 import Data.Function (($))
6 import Data.Functor ((<$>))
8 import Data.List ((++))
9 import Data.String (String, IsString(..))
10 import Data.Text (Text)
11 import System.FilePath (dropExtensions, takeBaseName, (</>), (<.>))
14 import Test.Tasty.Golden (goldenVsStringDiff)
15 import Text.Show (Show(..))
16 import qualified Data.List as List
17 import qualified Language.Haskell.TH as TH
18 import qualified Language.Haskell.TH.HideName as TH
19 import qualified System.Process as Process
21 import qualified Symantic.Parser as SP
23 import qualified Grammar
26 goldens = testGroup "Splice"
27 [ let spliceFile = getGoldenDir $ "Splice/"</>"G"++show gNum<.>"expected"<.>"txt" in
28 goldenVsStringDiff (takeBaseName (dropExtensions spliceFile)) goldenDiff spliceFile $ do
30 fromString <$> Process.readProcess "ormolu"
32 -- , "--no-dot-ormolu"
33 , "-o", "-XBangPatterns"
35 , "-o", "-XTypeApplications"
36 , "-o", "-XUnboxedTuples"
38 (show (TH.ppr (TH.hideName (TH.unType tExp))))
39 | (gNum, splice) <- List.zip [1::Int ..] splices
42 splices :: [IO (TH.TExp (Text -> SP.Parsed Text String))]
43 splices = (<$> Grammar.grammars) $ \g -> TH.runQ $ do
46 SP.optimizeMachine $ SP.optimizeGrammar g
47 TH.examineCode $ SP.generateCode mach
49 [ s1,s2,s3,s4,s5,s6,s7,s8,s9
50 ,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19