HUnit 1.6.1.0 → 1.6.2.0
raw patch · 5 files changed
+48/−42 lines, 5 filesdep ~call-stackPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: call-stack
API changes (from Hackage documentation)
- Test.HUnit.Base: (@=?) :: (HasCallStack, Eq a, Show a) => a -> a -> Assertion
+ Test.HUnit.Base: (@=?) :: HasCallStack => (Eq a, Show a) => a -> a -> Assertion
- Test.HUnit.Base: (@?) :: (HasCallStack, AssertionPredicable t) => t -> String -> Assertion
+ Test.HUnit.Base: (@?) :: HasCallStack => AssertionPredicable t => t -> String -> Assertion
- Test.HUnit.Base: (@?=) :: (HasCallStack, Eq a, Show a) => a -> a -> Assertion
+ Test.HUnit.Base: (@?=) :: HasCallStack => (Eq a, Show a) => a -> a -> Assertion
- Test.HUnit.Base: (~:) :: (HasCallStack, Testable t) => String -> t -> Test
+ Test.HUnit.Base: (~:) :: HasCallStack => Testable t => String -> t -> Test
- Test.HUnit.Base: (~=?) :: (HasCallStack, Eq a, Show a) => a -> a -> Test
+ Test.HUnit.Base: (~=?) :: HasCallStack => (Eq a, Show a) => a -> a -> Test
- Test.HUnit.Base: (~?) :: (HasCallStack, AssertionPredicable t) => t -> String -> Test
+ Test.HUnit.Base: (~?) :: HasCallStack => AssertionPredicable t => t -> String -> Test
- Test.HUnit.Base: (~?=) :: (HasCallStack, Eq a, Show a) => a -> a -> Test
+ Test.HUnit.Base: (~?=) :: HasCallStack => (Eq a, Show a) => a -> a -> Test
- Test.HUnit.Base: assertEqual :: (HasCallStack, Eq a, Show a) => String -> a -> a -> Assertion
+ Test.HUnit.Base: assertEqual :: HasCallStack => (Eq a, Show a) => String -> a -> a -> Assertion
- Test.HUnit.Lang: assertEqual :: (HasCallStack, Eq a, Show a) => String -> a -> a -> Assertion
+ Test.HUnit.Lang: assertEqual :: HasCallStack => (Eq a, Show a) => String -> a -> a -> Assertion
Files
- CHANGELOG.md +8/−0
- HUnit.cabal +4/−4
- src/Test/HUnit/Base.hs +22/−15
- src/Test/HUnit/Lang.hs +11/−4
- tests/HUnitTestExtended.hs +3/−19
CHANGELOG.md view
@@ -1,5 +1,13 @@ ## Changes +#### 1.6.2.0++- Add support for GHC 7.0.* and 7.2.*++#### 1.6.1.0++- Add `Test.HUnit.Text.runTestTTAndExit`+ #### 1.6.0.0 - Generalize return type of `assertFailure` to `IO a`
HUnit.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.3. -- -- see: https://github.com/sol/hpack name: HUnit-version: 1.6.1.0+version: 1.6.2.0 license: BSD3 license-file: LICENSE author: Dean Herington@@ -31,7 +31,7 @@ src build-depends: base ==4.*,- call-stack,+ call-stack >=0.3.0, deepseq exposed-modules: Test.HUnit.Base@@ -53,7 +53,7 @@ build-depends: HUnit, base ==4.*,- call-stack,+ call-stack >=0.3.0, deepseq, filepath other-modules:
src/Test/HUnit/Base.hs view
@@ -1,6 +1,13 @@-{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} +#if __GLASGOW_HASKELL__ >= 704+{-# LANGUAGE ConstraintKinds #-}+#define HasCallStack_ HasCallStack =>+#else+#define HasCallStack_+#endif+ -- | Basic definitions for the HUnit library. -- -- This module contains what you need to create assertions and test cases and@@ -52,16 +59,16 @@ -- ------------------------------- -- | Asserts that the specified condition holds.-assertBool :: HasCallStack- => String -- ^ The message that is displayed if the assertion fails+assertBool :: HasCallStack_+ String -- ^ The message that is displayed if the assertion fails -> Bool -- ^ The condition -> Assertion assertBool msg b = unless b (assertFailure msg) -- | Signals an assertion failure if a non-empty message (i.e., a message -- other than @\"\"@) is passed.-assertString :: HasCallStack- => String -- ^ The message that is displayed with the assertion failure+assertString :: HasCallStack_+ String -- ^ The message that is displayed with the assertion failure -> Assertion assertString s = unless (null s) (assertFailure s) @@ -79,7 +86,7 @@ -- If more complex arrangements of assertions are needed, 'Test's and -- 'Testable' should be used. class Assertable t- where assert :: HasCallStack => t -> Assertion+ where assert :: HasCallStack_ t -> Assertion instance Assertable () where assert = return@@ -95,7 +102,7 @@ -- | A specialized form of 'Assertable' to handle lists. class ListAssertable t- where listAssert :: HasCallStack => [t] -> Assertion+ where listAssert :: HasCallStack_ [t] -> Assertion instance ListAssertable Char where listAssert = assertString@@ -147,7 +154,7 @@ -- | Asserts that the condition obtained from the specified -- 'AssertionPredicable' holds.-(@?) :: (HasCallStack, AssertionPredicable t)+(@?) :: HasCallStack_ AssertionPredicable t => t -- ^ A value of which the asserted condition is predicated -> String -- ^ A message that is displayed if the assertion fails -> Assertion@@ -155,7 +162,7 @@ -- | Asserts that the specified actual value is equal to the expected value -- (with the expected value on the left-hand side).-(@=?) :: (HasCallStack, Eq a, Show a)+(@=?) :: HasCallStack_ (Eq a, Show a) => a -- ^ The expected value -> a -- ^ The actual value -> Assertion@@ -163,7 +170,7 @@ -- | Asserts that the specified actual value is equal to the expected value -- (with the actual value on the left-hand side).-(@?=) :: (HasCallStack, Eq a, Show a)+(@?=) :: HasCallStack_ (Eq a, Show a) => a -- ^ The actual value -> a -- ^ The expected value -> Assertion@@ -194,7 +201,7 @@ -- | Provides a way to convert data into a @Test@ or set of @Test@. class Testable t- where test :: HasCallStack => t -> Test+ where test :: HasCallStack_ t -> Test instance Testable Test where test = id@@ -214,7 +221,7 @@ -- | Creates a test case resulting from asserting the condition obtained -- from the specified 'AssertionPredicable'.-(~?) :: (HasCallStack, AssertionPredicable t)+(~?) :: HasCallStack_ AssertionPredicable t => t -- ^ A value of which the asserted condition is predicated -> String -- ^ A message that is displayed on test failure -> Test@@ -223,7 +230,7 @@ -- | Shorthand for a test case that asserts equality (with the expected -- value on the left-hand side, and the actual value on the right-hand -- side).-(~=?) :: (HasCallStack, Eq a, Show a)+(~=?) :: HasCallStack_ (Eq a, Show a) => a -- ^ The expected value -> a -- ^ The actual value -> Test@@ -232,7 +239,7 @@ -- | Shorthand for a test case that asserts equality (with the actual -- value on the left-hand side, and the expected value on the right-hand -- side).-(~?=) :: (HasCallStack, Eq a, Show a)+(~?=) :: HasCallStack_ (Eq a, Show a) => a -- ^ The actual value -> a -- ^ The expected value -> Test@@ -243,7 +250,7 @@ -- -- Since 'Test' is @Testable@, this can be used as a shorthand way of attaching -- a 'TestLabel' to one or more tests.-(~:) :: (HasCallStack, Testable t) => String -> t -> Test+(~:) :: HasCallStack_ Testable t => String -> t -> Test label ~: t = TestLabel label (test t)
src/Test/HUnit/Lang.hs view
@@ -1,7 +1,14 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE FlexibleContexts #-} +#if __GLASGOW_HASKELL__ >= 704+{-# LANGUAGE ConstraintKinds #-}+#define HasCallStack_ HasCallStack =>+#else+#define HasCallStack_+#endif+ module Test.HUnit.Lang ( Assertion, assertFailure,@@ -39,14 +46,14 @@ data FailureReason = Reason String | ExpectedButGot (Maybe String) String String deriving (Eq, Show, Typeable) -location :: HasCallStack => Maybe SrcLoc+location :: HasCallStack_ Maybe SrcLoc location = case reverse callStack of (_, loc) : _ -> Just loc [] -> Nothing -- | Unconditionally signals that a failure has occurred. assertFailure ::- HasCallStack =>+ HasCallStack_ String -- ^ A message that is displayed with the assertion failure -> IO a assertFailure msg = msg `deepseq` E.throwIO (HUnitFailure location $ Reason msg)@@ -57,7 +64,7 @@ -- -- If the prefix is the empty string (i.e., @\"\"@), then the prefix is omitted -- and only the expected and actual values are output.-assertEqual :: (HasCallStack, Eq a, Show a)+assertEqual :: HasCallStack_ (Eq a, Show a) => String -- ^ The message prefix -> a -- ^ The expected value -> a -- ^ The actual value
tests/HUnitTestExtended.hs view
@@ -1,34 +1,18 @@-{-# LANGUAGE CPP #-}-module HUnitTestExtended (- extendedTests- ) where+module HUnitTestExtended (extendedTests) where import Test.HUnit import HUnitTestBase -#if MIN_VERSION_base(4,9,0)-errorCall :: a-errorCall = error "error"-#endif- extendedTests :: Test extendedTests = test [-- -- Hugs doesn't currently catch arithmetic exceptions.- "div by 0" ~:- expectUnspecifiedError (TestCase ((3 `div` 0 :: Integer) `seq` return ())),+ expectError "divide by zero" (TestCase ((3 `div` 0 :: Integer) `seq` return ())), "list ref out of bounds" ~: expectUnspecifiedError (TestCase ([1 .. 4 :: Integer] !! 10 `seq` return ())), -#if MIN_VERSION_base(4,9,0)- "error" ~:- expectError "error\nCallStack (from HasCallStack):\n error, called at tests/HUnitTestExtended.hs:11:13 in main:HUnitTestExtended" (TestCase errorCall),-#else "error" ~:- expectError "error" (TestCase (error "error")),-#endif+ expectUnspecifiedError (TestCase (error "error")), "tail []" ~: expectUnspecifiedError (TestCase (tail [] `seq` return ()))