packages feed

doctest 0.5.1 → 0.5.2

raw patch · 3 files changed

+20/−14 lines, 3 files

Files

doctest.cabal view
@@ -1,5 +1,5 @@ name:             doctest-version:          0.5.1+version:          0.5.2 synopsis:         Test interactive Haskell examples description:      The doctest program checks examples in source code comments.                   It is modeled after doctest for Python
src/Main.hs view
@@ -21,7 +21,7 @@     docTests <- getDocTests haddockFlags files      let (tCount, iCount) = (length docTests, length (concatMap interactions docTests))-    hPutStrLn stderr $ "There are " ++ show tCount ++ " tests, with " ++ show iCount ++ " total interactions."+    hPutStrLn stderr (formatTestAndInteractionCount tCount iCount)      if DumpOnly `elem` options       then do@@ -34,3 +34,9 @@         if errCount == 0 && failCount == 0           then exitSuccess           else exitFailure+++formatTestAndInteractionCount :: Int -> Int -> String+formatTestAndInteractionCount 1 1           = "There is one test, with one single interaction."+formatTestAndInteractionCount 1 iCount      = "There is one test, with " ++ show iCount ++ " interactions."+formatTestAndInteractionCount tCount iCount = "There are " ++ show tCount ++ " tests, with " ++ show iCount ++ " total interactions."
src/Options.hs view
@@ -7,7 +7,8 @@  import Control.Monad (when) import System.Environment (getArgs)-import System.Exit+import System.Exit (exitSuccess, exitFailure)+import System.IO (hPutStr, stderr)  import System.Console.GetOpt @@ -39,24 +40,23 @@   args  <- getArgs   let (options, modules, errors) = getOpt Permute (documentedOptions ++ undocumentedOptions) args -  when (Help `elem` options)-    (printAndExit usage)+  when (Help `elem` options) $ do+    putStr usage+    exitSuccess -  when ((not . null) errors)-    (tryHelp $ head errors)+  when ((not . null) errors) $ do+    tryHelp $ head errors -  when (null modules)-    (tryHelp "no input files\n")+  when (null modules) $ do+    tryHelp "no input files\n"    return (options, modules)   where-    printAndExit :: String -> IO a-    printAndExit s = putStr s >> exitWith ExitSuccess-     usage = usageInfo "Usage: doctest [OPTION]... MODULE...\n" documentedOptions -    tryHelp message = printAndExit $ "doctest: " ++ message-      ++ "Try `doctest --help' for more information.\n"+    tryHelp message = do+      hPutStr stderr $ "doctest: " ++ message ++ "Try `doctest --help' for more information.\n"+      exitFailure   -- | Extract all ghc options from given list of options.