Test bootNGF and readNGF too, run tests on all three PGFs

This commit is contained in:
John J. Camilleri
2021-08-30 09:45:02 +02:00
parent f25b518186
commit 5c5e26cc8d

View File

@@ -6,16 +6,18 @@ import PGF2
main = do
x <- testLoadFailure "non-existing.pgf"
y <- testLoadFailure "tests/basic.gf"
gr <- readPGF "tests/basic.pgf"
gr1 <- readPGF "tests/basic.pgf"
gr2 <- bootNGF "tests/basic.pgf" "tests/basic.ngf"
gr3 <- readNGF "tests/basic.ngf"
g <- newStdGen
let limit = 10 ^ 100
let
limit = 10 ^ 100
ns = take 5000 (randomRs (-limit,limit) g)
runTestTTAndExit $
TestList [TestCase (assertBool "missing file" x)
,TestCase (assertBool "frong file format" y)
,TestCase (assertEqual "abstract names" "basic" (abstractName gr))
grammarTests :: PGF -> [Test]
grammarTests gr =
[TestCase (assertEqual "abstract names" "basic" (abstractName gr))
,TestCase (assertEqual "abstract categories" ["Float","Int","N","P","S","String"] (categories gr))
,TestCase (assertEqual "abstract functions" ["c","ind","s","z"] (functions gr))
,TestCase (assertEqual "abstract functions by cat 1" ["s","z"] (functionsByCat gr "N"))
@@ -73,6 +75,16 @@ main = do
,TestCase (assertEqual "unicode names 4" (Just "'а\\'б'") (fmap (showExpr []) (readExpr "'а\\'б'")))
]
runTestTTAndExit $
TestList $
[TestCase (assertBool "missing file" x)
,TestCase (assertBool "frong file format" y)
]
++ grammarTests gr1
++ grammarTests gr2
++ grammarTests gr3
testLoadFailure fpath = do
res <- try (readPGF fpath)
case res :: Either SomeException PGF of