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)
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
16 import Test.Tasty.Golden
18 import Language.Symantic.Grammar
19 import Language.Symantic
20 import Language.Symantic.Lib ()
22 -- * Golden testing utilities
23 testGolden :: TestName -> TestName -> IO BSL.ByteString -> TestTree
24 testGolden inputFile expectedExt =
25 goldenVsStringDiff inputFile diffGolden (inputFile <> expectedExt)
27 diffGolden :: FilePath -> FilePath -> [String]
28 diffGolden ref new = ["diff", "-u", ref, new]
31 goldensIO :: IO TestTree
33 -- inputFiles <- List.sort <$> findByExtension [".sym"] "test/Golden"
36 [ testGolden "grammar.ebnf" "" $ do
41 [ render <$> gram_comment
42 , render <$> gram_type
43 , render <$> gram_term
46 where render = TL.fromStrict . renderEBNF . unCF