Moved assertEither and assertEitherFail into TestUtil
This commit is contained in:
parent
4bb2b2a407
commit
5f57803616
|
@ -418,3 +418,11 @@ checkTempVarTypes testName vars is = mapM_ (checkTempVarType testName is) vars
|
|||
Nothing -> liftIO $ assertFailure (testName ++ ": spec does not have identifiable type for key \"" ++ key ++ "\": " ++ show (A.ndType nd))
|
||||
) state
|
||||
|
||||
assertEither :: (Eq a, Show a) => String -> a -> Either String a -> Assertion
|
||||
assertEither testName exp = assertEqual testName (Right exp)
|
||||
|
||||
assertEitherFail :: String -> Either String a -> Assertion
|
||||
assertEitherFail testName result
|
||||
= case result of
|
||||
Left _ -> return ()
|
||||
Right _ -> assertFailure $ testName ++ "; test expected to fail but passed"
|
||||
|
|
|
@ -233,17 +233,8 @@ 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 $ assertEither ("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 $ assertEitherFail ("testInitVar " ++ show testNum) $ checkInitVar (buildTestFlowGraph ns es start end v) (-1)
|
||||
|
|
Loading…
Reference in New Issue
Block a user