Changed the tests for checkInitVar so that they display the new error return upon failure

This commit is contained in:
Neil Brown 2007-11-02 11:45:22 +00:00
parent 8472f991d0
commit 153a1823a7

View File

@ -232,11 +232,20 @@ testInitVar = TestList
-- TODO test dereferenced variables
]
where
assertEither :: String -> Either String () -> Assertion
assertEither testName = assertEqual testName (Right ())
assertEitherFail :: String -> Either String () -> Assertion
assertEitherFail testName result
= case result of
Left _ -> return ()
Right _ -> assertFailure $ testName ++ "; test expected to fail but passed"
testInitVarPass :: Int -> [(Int, [Var], [Var], [Var])] -> [(Int, Int, EdgeLabel)] -> Int -> Int -> String -> Test
testInitVarPass testNum ns es start end v = TestCase $ assertBool ("testInitVar " ++ show testNum) $ checkInitVar (buildTestFlowGraph ns es start end v) (-1)
testInitVarPass testNum ns es start end v = TestCase $ assertEither ("testInitVar " ++ show testNum) $ checkInitVar (buildTestFlowGraph ns es start end v) (-1)
testInitVarFail :: Int -> [(Int, [Var], [Var], [Var])] -> [(Int, Int, EdgeLabel)] -> Int -> Int -> String -> Test
testInitVarFail testNum ns es start end v = TestCase $ assertBool ("testInitVar " ++ show testNum) $ not $ checkInitVar (buildTestFlowGraph ns es start end v) (-1)
testInitVarFail testNum ns es start end v = TestCase $ assertEitherFail ("testInitVar " ++ show testNum) $ checkInitVar (buildTestFlowGraph ns es start end v) (-1)
tests :: Test