]> Git — Sourcephile - haskell/symantic-parser.git/blob - tests/Golden/Grammar.hs
iface: add `HideName` instances
[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 Control.Monad (Monad(..))
7 import Data.Bool (Bool(..))
8 import Data.Function (($))
9 import Data.Int (Int)
10 import Data.Semigroup (Semigroup(..))
11 import Data.String (IsString(..))
12 import Test.Tasty
13 import Test.Tasty.Golden
14 import Text.Show (Show(..))
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 ]