]> Git — Sourcephile - haskell/symantic-parser.git/blob - test/Golden/Grammar.hs
doc: fix license and {def => shareable}
[haskell/symantic-parser.git] / test / Golden / Grammar.hs
1 {-# LANGUAGE DataKinds #-} -- For using P.viewGrammar
2 {-# LANGUAGE Rank2Types #-}
3 {-# LANGUAGE TypeApplications #-}
4 module Golden.Grammar where
5
6 import Data.Bool (Bool(..))
7 import Control.Monad (Monad(..))
8 import Data.Function (($))
9 import Data.Semigroup (Semigroup(..))
10 import Data.String (IsString(..))
11 import Test.Tasty
12 import Test.Tasty.Golden
13 import Text.Show (Show(..))
14 import Data.Int (Int)
15 import qualified Data.List as List
16
17 import Golden.Utils
18 import qualified Symantic.Parser as P
19 import qualified Grammar
20
21 goldens :: TestTree
22 goldens = testGroup "Grammar" $
23 [ testGroup "ViewGrammar" $
24 (\f -> List.zipWith f Grammar.grammars [1::Int ..]) $ \gram g ->
25 let grammarFile = getGoldenDir $ "Grammar/ViewGrammar/G"<>show g<>".expected.txt" in
26 goldenVsStringDiff ("G"<>show g) goldenDiff grammarFile $ do
27 resetTHNameCounter
28 return $ fromString $ show $
29 P.viewGrammar @'False gram
30 , testGroup "OptimizeGrammar" $
31 (\f -> List.zipWith f Grammar.grammars [1::Int ..]) $ \gram g ->
32 let grammarFile = getGoldenDir $ "Grammar/OptimizeGrammar/G"<>show g<>".expected.txt" in
33 goldenVsStringDiff ("G"<>show g) goldenDiff grammarFile $ do
34 resetTHNameCounter
35 return $ fromString $ show $
36 P.viewGrammar @'False $
37 P.optimizeGrammar gram
38 ]