mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
test cases for the concrete syntax
This commit is contained in:
@@ -62,4 +62,5 @@ test-suite transactions
|
||||
build-depends:
|
||||
base,
|
||||
HUnit >= 1.6.1.0,
|
||||
containers,
|
||||
pgf2
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user