tasty-hunit (empty) → 0.1
raw patch · 4 files changed
+100/−0 lines, 4 filesdep +HUnitdep +basedep +mtlsetup-changed
Dependencies added: HUnit, base, mtl, tasty
Files
- LICENSE +19/−0
- Setup.hs +2/−0
- Test/Tasty/HUnit.hs +55/−0
- tasty-hunit.cabal +24/−0
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2013 Roman Cheplyaka++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ Test/Tasty/HUnit.hs view
@@ -0,0 +1,55 @@+-- | This module allows to use HUnit tests in tasty. +{-# LANGUAGE TypeFamilies, DeriveDataTypeable #-}+module Test.Tasty.HUnit (testCase) where++import Test.Tasty.Providers++import qualified Test.HUnit.Base+import Test.HUnit.Lang++import Data.Typeable+import Control.Monad.Trans++-- | Create a 'Test' for a HUnit 'Assertion'+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++ 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
@@ -0,0 +1,24 @@+-- Initial tasty-hunit.cabal generated by cabal init. For further +-- documentation, see http://haskell.org/cabal/users-guide/++name: tasty-hunit+version: 0.1+synopsis: HUnit support for the Tasty test framework.+description: HUnit support for the Tasty test framework.+license: MIT+license-file: LICENSE+author: Roman Cheplyaka+maintainer: roma@ro-che.info+-- copyright: +category: Testing+build-type: Simple+-- extra-source-files: +cabal-version: >=1.10++library+ exposed-modules: Test.Tasty.HUnit+ -- other-modules: + other-extensions: TypeFamilies, DeriveDataTypeable+ build-depends: base ==4.*, tasty, HUnit, mtl+ -- hs-source-dirs: + default-language: Haskell2010