forked from GitHub/gf-core
Add more test cases for read/boot failures, those which incorrectly fail are commented out
This commit is contained in:
@@ -4,12 +4,6 @@ import Test.HUnit
|
||||
import PGF2
|
||||
|
||||
main = do
|
||||
x <- testLoadFailure "non-existing.pgf"
|
||||
y <- testLoadFailure "tests/basic.gf"
|
||||
gr1 <- readPGF "tests/basic.pgf"
|
||||
gr2 <- bootNGF "tests/basic.pgf" "tests/basic.ngf"
|
||||
gr3 <- readNGF "tests/basic.ngf"
|
||||
|
||||
g <- newStdGen
|
||||
let
|
||||
limit = 10 ^ 100
|
||||
@@ -75,18 +69,43 @@ main = do
|
||||
,TestCase (assertEqual "unicode names 4" (Just "'а\\'б'") (fmap (showExpr []) (readExpr "'а\\'б'")))
|
||||
]
|
||||
|
||||
gr1 <- readPGF "tests/basic.pgf"
|
||||
gr2 <- bootNGF "tests/basic.pgf" "tests/basic.ngf"
|
||||
gr3 <- readNGF "tests/basic.ngf"
|
||||
|
||||
rp1 <- testLoadFailure (readPGF "non-existing.pgf")
|
||||
rp2 <- testLoadFailure (readPGF "tests/basic.gf")
|
||||
-- rp3 <- testLoadFailure (readPGF "tests/basic.ngf")
|
||||
|
||||
bn1 <- testLoadFailure (bootNGF "non-existing.pgf" "non-existing.ngf")
|
||||
bn2 <- testLoadFailure (bootNGF "tests/basic.gf" "tests/basic.ngf")
|
||||
bn3 <- testLoadFailure (bootNGF "tests/basic.ngf" "tests/basic.pgf")
|
||||
|
||||
-- rn1 <- testLoadFailure (readNGF "non-existing.ngf")
|
||||
-- rn2 <- testLoadFailure (readNGF "tests/basic.gf")
|
||||
-- rn3 <- testLoadFailure (readNGF "tests/basic.pgf")
|
||||
|
||||
runTestTTAndExit $
|
||||
TestList $
|
||||
[TestCase (assertBool "missing file" x)
|
||||
,TestCase (assertBool "frong file format" y)
|
||||
[TestCase (assertBool "missing file" rp1)
|
||||
,TestCase (assertBool "wrong file format (GF)" rp2)
|
||||
-- ,TestCase (assertBool "wrong file format (NGF)" rp3)
|
||||
|
||||
,TestCase (assertBool "missing file" bn1)
|
||||
,TestCase (assertBool "wrong file format (GF)" bn2)
|
||||
,TestCase (assertBool "wrong file format (NGF)" bn3)
|
||||
|
||||
-- ,TestCase (assertBool "missing file" rn1)
|
||||
-- ,TestCase (assertBool "wrong file format (GF)" rn2)
|
||||
-- ,TestCase (assertBool "wrong file format (PGF)" rn3)
|
||||
]
|
||||
++ grammarTests gr1
|
||||
++ grammarTests gr2
|
||||
++ grammarTests gr3
|
||||
|
||||
|
||||
testLoadFailure fpath = do
|
||||
res <- try (readPGF fpath)
|
||||
testLoadFailure io = do
|
||||
res <- try io
|
||||
case res :: Either SomeException PGF of
|
||||
Left _ -> return True
|
||||
Right _ -> return False
|
||||
|
||||
Reference in New Issue
Block a user