test-framework-hunit (empty) → 0.2.0
raw patch · 5 files changed
+116/−0 lines, 5 filesdep +HUnitdep +basedep +test-frameworksetup-changed
Dependencies added: HUnit, base, test-framework
Files
- LICENSE +22/−0
- README.textile +3/−0
- Setup.lhs +4/−0
- Test/Framework/Providers/HUnit.hs +56/−0
- test-framework-hunit.cabal +31/−0
+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 2008, Maximilian Bolingbroke+All rights reserved.++Redistribution and use in source and binary forms, with or without modification, are permitted+provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright notice, this list of+ conditions and the following disclaimer.+ * Redistributions in binary form must reproduce the above copyright notice, this list of+ conditions and the following disclaimer in the documentation and/or other materials+ provided with the distribution.+ * Neither the name of Maximilian Bolingbroke nor the names of other contributors may be used to+ endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT+OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.textile view
@@ -0,0 +1,3 @@+h1. Test Framework HUnit Support++For more information, please see the latest version of the test-framework package README. This can be found at the "GitHub wiki":http://github.com/batterseapower/test-framework/wikis/readme.
+ Setup.lhs view
@@ -0,0 +1,4 @@+#! /usr/bin/env runhaskell++> import Distribution.Simple+> main = defaultMain
+ Test/Framework/Providers/HUnit.hs view
@@ -0,0 +1,56 @@+module Test.Framework.Providers.HUnit (+ testCase+ ) where++import Test.Framework.Providers.API++import Test.HUnit.Lang+++-- | Create a 'Test' for a HUnit 'Assertion'+testCase :: TestName -> Assertion -> Test+testCase name = Test name . TestCase+++instance TestResultlike TestCaseRunning TestCaseResult where+ testSucceeded = testCaseSucceeded++data TestCaseRunning = TestCaseRunning++instance Show TestCaseRunning where+ show TestCaseRunning = "Running"++data TestCaseResult = TestCasePassed+ | TestCaseFailed String+ | TestCaseError String++instance Show TestCaseResult where+ show result = case result of+ TestCasePassed -> "OK"+ TestCaseFailed message -> "Failed: " ++ message+ TestCaseError message -> "ERROR: " ++ message++testCaseSucceeded :: TestCaseResult -> Bool+testCaseSucceeded TestCasePassed = True+testCaseSucceeded _ = False+++newtype TestCase = TestCase Assertion++instance Testlike TestCaseRunning TestCaseResult TestCase where+ runTest topts (TestCase assertion) = runTestCase topts assertion+ testTypeName _ = "Test Cases"++runTestCase :: CompleteTestOptions -> Assertion -> IO (TestCaseRunning :~> TestCaseResult, IO ())+runTestCase topts assertion = runImprovingIO $ do+ yieldImprovement TestCaseRunning+ mb_result <- maybeTimeoutImprovingIO (unK $ topt_timeout topts) $ liftIO (myPerformTestCase assertion)+ return (mb_result `orElse` TestCaseError "Timed out")++myPerformTestCase :: Assertion -> IO TestCaseResult+myPerformTestCase assertion = do+ result <- performTestCase assertion+ return $ case result of+ Nothing -> TestCasePassed+ Just (True, message) -> TestCaseFailed message+ Just (False, message) -> TestCaseError message
+ test-framework-hunit.cabal view
@@ -0,0 +1,31 @@+Name: test-framework-hunit+Version: 0.2.0+Cabal-Version: >= 1.2+Category: Testing+Synopsis: HUnit support for the test-framework package.+License: BSD3+License-File: LICENSE+Extra-Source-Files: README.textile+Author: Max Bolingbroke+Maintainer: batterseapower@hotmail.com+Homepage: http://github.com/batterseapower/test-framework+Build-Type: Simple++Flag SplitBase+ Description: Choose the new smaller, split-up base package+ Default: True+++Library+ Exposed-Modules: Test.Framework.Providers.HUnit+ + Build-Depends: test-framework >= 0.2.0, HUnit >= 1.2 && < 2+ if flag(splitBase)+ Build-Depends: base >= 3+ else+ Build-Depends: base < 3+ + Extensions: TypeOperators+ MultiParamTypeClasses+ + Ghc-Options: -Wall