1 {-# LANGUAGE DataKinds #-} -- For using P.viewGrammar
2 {-# LANGUAGE Rank2Types #-}
3 {-# LANGUAGE TypeApplications #-}
4 module Golden.Grammar where
6 import Data.Bool (Bool(..))
7 import Control.Monad (Monad(..))
8 import Data.Function (($))
9 import Data.Semigroup (Semigroup(..))
10 import Data.String (IsString(..))
12 import Test.Tasty.Golden
13 import Text.Show (Show(..))
15 import qualified Data.List as List
18 import qualified Symantic.Parser as P
19 import qualified Grammar
22 goldens = testGroup "Grammar" $
23 [ testGroup "ViewGrammar" $
24 (\f -> List.zipWith f Grammar.grammars [1::Int ..]) $ \gram g ->
25 let grammarFile = "test/Golden/Grammar/ViewGrammar/G"<>show g<>".expected.txt" in
26 goldenVsStringDiff ("G"<>show g) goldenDiff grammarFile $ do
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 = "test/Golden/Grammar/OptimizeGrammar/G"<>show g<>".expected.txt" in
33 goldenVsStringDiff ("G"<>show g) goldenDiff grammarFile $ do
35 return $ fromString $ show $
36 P.viewGrammar @'False $
37 P.optimizeGrammar gram