packages feed

tasty-hunit 0.1 → 0.2

raw patch · 2 files changed

+37/−35 lines, 2 files

Files

Test/Tasty/HUnit.hs view
@@ -1,11 +1,32 @@ -- | This module allows to use HUnit tests in tasty.  {-# LANGUAGE TypeFamilies, DeriveDataTypeable #-}-module Test.Tasty.HUnit (testCase) where+module Test.Tasty.HUnit+  ( testCase+  -- | We only re-export parts of "Test.HUnit.Base" related to assertions+  -- and not tests.+  , module Test.HUnit.Base+  ) where  import Test.Tasty.Providers  import qualified Test.HUnit.Base import Test.HUnit.Lang+import Test.HUnit.Base hiding -- for re-export+  ( Test(..)+  , (~=?)+  , (~?=)+  , (~:)+  , (~?)+  , State(..)+  , Counts(..)+  , Path+  , Node+  , testCasePaths+  , testCaseCount+  , ReportStart+  , ReportProblem+  , performTest+  )  import Data.Typeable import Control.Monad.Trans@@ -14,42 +35,23 @@ testCase :: TestName -> Assertion -> TestTree testCase name = singleTest name . TestCase -data TestCaseResult-  = TestCasePassed-  | TestCaseFailed String-  | TestCaseError String--describe r =-  case r of-    TestCasePassed         -> ""-    TestCaseFailed message -> message-    TestCaseError message  -> message--testCaseSucceeded :: TestCaseResult -> Bool-testCaseSucceeded TestCasePassed = True-testCaseSucceeded _              = False- newtype TestCase = TestCase Assertion     deriving Typeable  instance IsTest TestCase where-  run _ (TestCase assertion) _ =-    myPerformTestCase assertion+  run _ (TestCase assertion) _ = do+    hunitResult <- performTestCase assertion+    return $+      case hunitResult of+        Nothing ->+          Result+            { resultSuccessful = True+            , resultDescription = ""+            }+        Just (_, message)  ->+          Result+            { resultSuccessful = False+            , resultDescription = message+            }    testOptions = return []--myPerformTestCase :: Assertion -> IO Result-myPerformTestCase assertion = do-    hunitResult <- performTestCase assertion-    let-      tcResult =-        case hunitResult of-          Nothing               -> TestCasePassed-          Just (True, message)  -> TestCaseFailed message-          Just (False, message) -> TestCaseError message-      result =-        Result-          { resultSuccessful = testCaseSucceeded tcResult-          , resultDescription = describe tcResult-          }-    return result
tasty-hunit.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                tasty-hunit-version:             0.1+version:             0.2 synopsis:            HUnit support for the Tasty test framework. description:         HUnit support for the Tasty test framework. license:             MIT