]> Git — Sourcephile - haskell/symantic.git/blob - symantic-lib/test/Golden.hs
Add Trans defaults.
[haskell/symantic.git] / symantic-lib / test / Golden.hs
1 module Golden where
2
3 import Control.Monad (Monad(..))
4 import Data.Function (($), (.))
5 import Data.Functor ((<$>))
6 import Data.Semigroup (Semigroup(..))
7 import Data.String (String)
8 -- import System.FilePath (FilePath)
9 import System.IO (IO)
10 import qualified Data.ByteString.Lazy as BSL
11 import qualified Data.List as List
12 import qualified Data.Text.Lazy as TL
13 import qualified Data.Text.Lazy.Encoding as TL
14
15 import Test.Tasty
16 import Test.Tasty.Golden
17
18 import Language.Symantic.Grammar
19 import Language.Symantic
20 import Language.Symantic.Lib ()
21
22 -- * Golden testing utilities
23 testGolden :: TestName -> TestName -> IO BSL.ByteString -> TestTree
24 testGolden inputFile expectedExt =
25 goldenVsStringDiff inputFile diffGolden (inputFile <> expectedExt)
26
27 diffGolden :: FilePath -> FilePath -> [String]
28 diffGolden ref new = ["diff", "-u", ref, new]
29
30 -- * All golden tests
31 goldensIO :: IO TestTree
32 goldensIO = do
33 -- inputFiles <- List.sort <$> findByExtension [".sym"] "test/Golden"
34 return $
35 testGroup "Golden"
36 [ testGolden "grammar.ebnf" "" $ do
37 return $
38 TL.encodeUtf8 $
39 TL.unlines $
40 List.concat
41 [ render <$> gram_comment
42 , render <$> gram_type
43 , render <$> gram_term
44 ]
45 ]
46 where render = TL.fromStrict . renderEBNF . unCF