mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 19:22:50 -06:00
test that we can handle loading failures
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
|
import Control.Exception
|
||||||
import Test.HUnit
|
import Test.HUnit
|
||||||
import PGF2
|
import PGF2
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
|
x <- testLoadFailure "non-existing.pgf"
|
||||||
|
x <- testLoadFailure "tests/basic.gf"
|
||||||
gr <- readPGF "tests/basic.pgf"
|
gr <- readPGF "tests/basic.pgf"
|
||||||
runTestTTAndExit $
|
runTestTTAndExit $
|
||||||
TestList [TestCase (assertEqual "abstract names" "basic" (abstractName gr))
|
TestList [TestCase (assertBool "loading failure handled" x)
|
||||||
|
,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"))
|
||||||
@@ -23,5 +27,11 @@ main = do
|
|||||||
,TestCase (assertEqual "function is constructor 4" False (functionIsConstructor gr "ind"))
|
,TestCase (assertEqual "function is constructor 4" False (functionIsConstructor gr "ind"))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
testLoadFailure fpath = do
|
||||||
|
res <- try (readPGF fpath)
|
||||||
|
case res :: Either SomeException PGF of
|
||||||
|
Left _ -> return True
|
||||||
|
Right _ -> return False
|
||||||
|
|
||||||
eqJust (Just x) (Just y) = x == y
|
eqJust (Just x) (Just y) = x == y
|
||||||
eqJust _ _ = False
|
eqJust _ _ = False
|
||||||
|
|||||||
Reference in New Issue
Block a user