test-sandbox-hunit (empty) → 0.0.1
raw patch · 4 files changed
+101/−0 lines, 4 filesdep +HUnitdep +basedep +lifted-basesetup-changed
Dependencies added: HUnit, base, lifted-base, test-sandbox
Files
- LICENSE +25/−0
- Setup.lhs +4/−0
- src/Test/Sandbox/HUnit.hs +51/−0
- test-sandbox-hunit.cabal +21/−0
+ LICENSE view
@@ -0,0 +1,25 @@+The BSD 3-Clause License+========================++Copyright (c) 2013, GREE+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 GREE, 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.
+ Setup.lhs view
@@ -0,0 +1,4 @@+#! /usr/bin/env runhaskell++> import Distribution.Simple+> main = defaultMain
+ src/Test/Sandbox/HUnit.hs view
@@ -0,0 +1,51 @@+-- author: Benjamin Surma <benjamin.surma@gree.net>++module Test.Sandbox.HUnit (+ assertFailure+ , assertBool+ , assertEqual+ , assertString+ , assertException+ ) where++import Test.Sandbox++import Control.Exception.Lifted++import qualified Test.HUnit+import Test.HUnit.Lang (HUnitFailure (..))++-- | Unconditionally signals that a failure has occured.+assertFailure :: String -- ^ A message that is displayed with the assertion failure+ -> Sandbox ()+assertFailure = wrap . liftIO . Test.HUnit.assertFailure++-- | Asserts that the specified condition holds.+assertBool :: String -- ^ The message that is displayed if the assertion fails+ -> Bool -- ^ The condition+ -> Sandbox ()+assertBool s b = wrap $ liftIO (Test.HUnit.assertBool s b)++-- | Asserts that the specified actual value is equal to the expected value.+assertEqual :: (Eq a, Show a)+ => String -- ^ The message prefix+ -> a -- ^ The expected value+ -> a -- ^ The actual value+ -> Sandbox ()+assertEqual s a b = wrap $ liftIO (Test.HUnit.assertEqual s a b)++-- | Signals an assertion failure if a non-empty message (i.e., a message other than "") is passed.+assertString :: String -- ^ The message that is displayed with the assertion failure+ -> Sandbox ()+assertString s = wrap $ liftIO (Test.HUnit.assertString s)++-- | Signals an assertion failure if *no* exception is raised.+assertException :: String -- ^ The message that is displayed with the assertion failure+ -> Sandbox a+ -> Sandbox ()+assertException s a =+ assertBool s =<< (a >> return False) `catchError` const (return True)++wrap :: Sandbox () -> Sandbox ()+wrap action = action `catches` [ Handler hunitHandler ]+ where hunitHandler (HUnitFailure e) = throwError e
+ test-sandbox-hunit.cabal view
@@ -0,0 +1,21 @@+Name: test-sandbox-hunit+Version: 0.0.1+Cabal-Version: >= 1.14+Category: Testing+Synopsis: HUnit convenience functions for use with test-sandbox+Description: This package provides wrappers around the Test.HUnit unit-test functions,+ allowing them to be used easily in the Test.Sandbox monad provided by the test-sandbox package.+License: BSD3+License-File: LICENSE+Author: Benjamin Surma <benjamin.surma@gree.net>+Maintainer: Benjamin Surma <benjamin.surma@gree.net>+Build-Type: Simple++Library+ Exposed-modules: Test.Sandbox.HUnit++ Build-Depends: base >=4 && <5, lifted-base, test-sandbox == 0.0.1.*, HUnit++ Hs-source-dirs: src++ Default-Language: Haskell2010