From 153a1823a75227a00a734c77b50471480c420153 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 2 Nov 2007 11:45:22 +0000 Subject: [PATCH] Changed the tests for checkInitVar so that they display the new error return upon failure --- transformations/RainUsageCheckTest.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/transformations/RainUsageCheckTest.hs b/transformations/RainUsageCheckTest.hs index 1318365..3cbde03 100644 --- a/transformations/RainUsageCheckTest.hs +++ b/transformations/RainUsageCheckTest.hs @@ -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