packages feed

HUnit 1.2.2.3 → 1.2.4.2

raw patch · 4 files changed

+122/−4 lines, 4 filesdep ~basenew-component:exe:optimize-1-testsPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

HUnit.cabal view
@@ -1,5 +1,5 @@ Name:                   HUnit-Version:                1.2.2.3+Version:                1.2.4.2 Cabal-Version:          >= 1.6 License:                BSD3 License-File:           LICENSE@@ -13,7 +13,8 @@     HUnit is a unit testing framework for Haskell, inspired by the     JUnit tool for Java, see: <http://www.junit.org>. Tested-With:-    GHC == 6.10.4+    GHC == 6.12.3+    GHC == 7.0.3 Build-Type:             Custom Extra-Source-Files:     tests/HUnitTest98.lhs@@ -92,3 +93,56 @@     if impl(ghc >= 6.10)         Build-Depends: base >=4         Extensions: CPP++-- Commenting these tests out because Hackage doesn't+-- accept packages that specify optimization level,+-- which is a key component of these tests.+--Executable optimize-0-tests+--    Main-Is:            HUnitTestOptimize.hs+--    HS-Source-Dirs:     . tests+--    Build-Depends:      base<5+--    GHC-Options:        -O0+--    if flag(base4)+--        Build-Depends: base >=4+--        CPP-Options: -DBASE4+--        GHC-Options: -Wall+--    else+--        Build-Depends: base <4+--    if impl(ghc >= 6.10)+--        Build-Depends: base >=4+--        Extensions: CPP+        +Executable optimize-1-tests+    Main-Is:            HUnitTestOptimize.hs+    HS-Source-Dirs:     . tests+    Build-Depends:      base<5+-- Commenting out this line because, at the time of writing, -O1 is implied and+-- the issue, that tests are optimized out of existence, is exposed at this +-- optimization level.+--    GHC-Options:        -O1+    if flag(base4)+        Build-Depends: base >=4+        CPP-Options: -DBASE4+        GHC-Options: -Wall+    else+        Build-Depends: base <4+    if impl(ghc >= 6.10)+        Build-Depends: base >=4+        Extensions: CPP+        +-- Commented out for the same reason as optimize-0-tests.+--Executable optimize-2-tests+--    Main-Is:            HUnitTestOptimize.hs+--    HS-Source-Dirs:     . tests+--    Build-Depends:      base<5+--    GHC-Options:        -O2+--    if flag(base4)+--        Build-Depends: base >=4+--        CPP-Options: -DBASE4+--        GHC-Options: -Wall+--    else+--        Build-Depends: base <4+--    if impl(ghc >= 6.10)+--        Build-Depends: base >=4+--        Extensions: CPP+        
Test/HUnit/Lang.hs view
@@ -78,13 +78,21 @@ #ifdef BASE4
 instance Exception HUnitFailure
 
-assertFailure msg = E.throw (HUnitFailure msg)
+assertFailure msg = E.throwIO (HUnitFailure msg)
 
 performTestCase action = 
     do action
        return Nothing
      `E.catches`
       [E.Handler (\(HUnitFailure msg) -> return $ Just (True, msg)),
+
+       -- Re-throw AsyncException, otherwise execution will not terminate on
+       -- SIGINT (ctrl-c).  Currently, all AsyncExceptions are being thrown
+       -- because it's thought that none of them will be encountered during
+       -- normal HUnit operation.  If you encounter an example where this
+       -- is not the case, please email the maintainer.
+       E.Handler (\e -> throw (e :: E.AsyncException)),
+
        E.Handler (\e -> return $ Just (False, show (e :: E.SomeException)))]
 #else
 assertFailure msg = E.throwDyn (HUnitFailure msg)
+ tests/HUnitTestOptimize.hs view
@@ -0,0 +1,36 @@+-- HUnitTestOptimize.hs+--+-- The purpose of this file is to test whether certain issues occur with optimization.+-- It should be built and run with each level of optimization.  I.e., -O0, -O1, -O2++module Main (main) where++import Control.Monad (unless)+import Test.HUnit++simpleTestRunner :: Test -> IO Counts+simpleTestRunner t = do +    (counts', _) <- runTestText nullAccum t+    return counts'+    where+        nullAccum = PutText (\ _ _ _ -> return ()) ()++main :: IO Counts+main = do+    counts2 <- simpleTestRunner $ TestList [ +        True ~=? True,+        False ~=? True,+        TestCase $ assertEqual "both true" True True,+        TestCase $ assertEqual "false true" False True,+        TestCase $ assertEqual "fa" False True,+        TestCase $ assertEqual "f" False True,+        TestCase $ (False @?= True),+        TestCase $ unless (False == True) (assertFailure "f")+        ]+    counts3 <- runTestTT $ TestList [+        TestCase $ assertEqual "Number of cases" (cases counts2) 8,+        TestCase $ assertEqual "Number of cases tried" (tried counts2) 8,+        TestCase $ assertEqual "Number of failures" (failures counts2) 6+        ]+    putStrLn "There should be 3 cases, 3 tried, and 0 errors and 0 failures."+    return counts3
tests/HUnitTests.cabal view
@@ -25,4 +25,24 @@ HS-Source-Dirs:         . .. -- Build-Depends:          base Extensions:             CPP-    ++Executable:             optimize-tests-O0+Main-Is:                HUnitTestOptimize.hs+HS-Source-Dirs:         . ..+-- Build-Depends:          base+Extensions:             CPP+GHC-Options:            -O0++Executable:             optimize-tests-O1+Main-Is:                HUnitTestOptimize.hs+HS-Source-Dirs:         . ..+-- Build-Depends:          base+Extensions:             CPP+GHC-Options:            -O1++Executable:             optimize-tests-O2+Main-Is:                HUnitTestOptimize.hs+HS-Source-Dirs:         . ..+-- Build-Depends:          base+Extensions:             CPP+GHC-Options:            -O2