test cases for the concrete syntax

This commit is contained in:
krangelov
2021-11-03 11:40:34 +01:00
parent 309a16d471
commit 43f40e701a
2 changed files with 10 additions and 0 deletions

View File

@@ -62,4 +62,5 @@ test-suite transactions
build-depends:
base,
HUnit >= 1.6.1.0,
containers,
pgf2

View File

@@ -3,6 +3,7 @@ import PGF2
import PGF2.Transactions
import System.Mem
import System.Exit (exitSuccess, exitFailure)
import qualified Data.Map as Map
main = do
gr1 <- readPGF "tests/basic.pgf"
@@ -18,6 +19,11 @@ main = do
gr6 <- modifyPGF gr1 (dropFunction "ind" >> dropCategory "S")
gr7 <- modifyPGF gr1 $
createConcrete "basic_eng" $ do
setConcreteFlag "test_flag" (LStr "test")
let Just cnc = Map.lookup "basic_eng" (languages gr7)
c <- runTestTT $
TestList $
[TestCase (assertEqual "original functions" ["c","ind","s","z"] (functions gr1))
@@ -38,6 +44,9 @@ main = do
,TestCase (assertEqual "new function prob" pi (functionProbability gr2 "foo"))
,TestCase (assertEqual "old category prob" (-log 0) (categoryProbability gr1 "Q"))
,TestCase (assertEqual "new category prob" pi (categoryProbability gr2 "Q"))
,TestCase (assertEqual "empty concretes" [] (Map.keys (languages gr1)))
,TestCase (assertEqual "extended concretes" ["basic_eng"] (Map.keys (languages gr7)))
,TestCase (assertEqual "added concrete flag" (Just (LStr "test")) (concreteFlag cnc "test_flag"))
]
performMajorGC