mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-22 09:32:53 -06:00
Test bootNGF and readNGF too, run tests on all three PGFs
This commit is contained in:
@@ -6,16 +6,18 @@ import PGF2
|
|||||||
main = do
|
main = do
|
||||||
x <- testLoadFailure "non-existing.pgf"
|
x <- testLoadFailure "non-existing.pgf"
|
||||||
y <- testLoadFailure "tests/basic.gf"
|
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
|
g <- newStdGen
|
||||||
let limit = 10 ^ 100
|
let
|
||||||
|
limit = 10 ^ 100
|
||||||
ns = take 5000 (randomRs (-limit,limit) g)
|
ns = take 5000 (randomRs (-limit,limit) g)
|
||||||
|
|
||||||
runTestTTAndExit $
|
grammarTests :: PGF -> [Test]
|
||||||
TestList [TestCase (assertBool "missing file" x)
|
grammarTests gr =
|
||||||
,TestCase (assertBool "frong file format" y)
|
[TestCase (assertEqual "abstract names" "basic" (abstractName gr))
|
||||||
,TestCase (assertEqual "abstract names" "basic" (abstractName gr))
|
|
||||||
,TestCase (assertEqual "abstract categories" ["Float","Int","N","P","S","String"] (categories 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" ["c","ind","s","z"] (functions gr))
|
||||||
,TestCase (assertEqual "abstract functions by cat 1" ["s","z"] (functionsByCat gr "N"))
|
,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 "'а\\'б'")))
|
,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
|
testLoadFailure fpath = do
|
||||||
res <- try (readPGF fpath)
|
res <- try (readPGF fpath)
|
||||||
case res :: Either SomeException PGF of
|
case res :: Either SomeException PGF of
|
||||||
|
|||||||
Reference in New Issue
Block a user