diff --git a/common/TestUtil.hs b/common/TestUtil.hs index 8536ce6..38930bb 100644 --- a/common/TestUtil.hs +++ b/common/TestUtil.hs @@ -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" diff --git a/transformations/RainUsageCheckTest.hs b/transformations/RainUsageCheckTest.hs index 76e46e7..de3096e 100644 --- a/transformations/RainUsageCheckTest.hs +++ b/transformations/RainUsageCheckTest.hs @@ -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)