]> Git — Sourcephile - haskell/symantic-parser.git/blob - tests/Golden/Grammar.hs
doc: update `ChangeLog.md`
[haskell/symantic-parser.git] / tests / 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 ..]) $ \g gNum ->
25 let grammarFile = getGoldenDir $ "Grammar/ViewGrammar/G"<>show gNum<>".expected.txt" in
26 goldenVsStringDiff ("G"<>show gNum) goldenDiff grammarFile $ do
27 resetTHNameCounter
28 return $ fromString $ show $
29 P.viewGrammar @'False g
30 , testGroup "OptimizeGrammar" $
31 (\f -> List.zipWith f Grammar.grammars [1::Int ..]) $ \g gNum ->
32 let grammarFile = getGoldenDir $ "Grammar/OptimizeGrammar/G"<>show gNum<>".expected.txt" in
33 goldenVsStringDiff ("G"<>show gNum) goldenDiff grammarFile $ do
34 resetTHNameCounter
35 return $ fromString $ show $
36 P.viewGrammar @'False $
37 P.optimizeGrammar g
38 ]