microspec 0.2.0.0 → 0.2.0.1
raw patch · 2 files changed
+15/−8 lines, 2 filesdep +timedep ~QuickCheckPVP ok
version bump matches the API change (PVP)
Dependencies added: time
Dependency ranges changed: QuickCheck
API changes (from Hackage documentation)
Files
- Test/Microspec.hs +11/−7
- microspec.cabal +4/−1
Test/Microspec.hs view
@@ -22,7 +22,7 @@ -- __is commutative__ -- -- -------- Successes: 3, Pending: 0, Failures: 0+-- __Successes: 3, Pending: 0, Failures: 0__ -- @ {-# LANGUAGE@@ -55,9 +55,10 @@ -- , module Test.QuickCheck.Property ) where +import Control.Monad import Data.Char (isSpace) import Data.Maybe (mapMaybe)-import Control.Monad+import Data.Time (getCurrentTime, diffUTCTime) import System.Exit (exitWith, ExitCode(ExitFailure)) -- import Data.Time (getCurrentTime, diffUTCTime) import Test.QuickCheck as QC@@ -99,18 +100,20 @@ microspecWith :: MArgs -> Microspec () -> IO () microspecWith args spec = do putStrLn ""+ startTime <- getCurrentTime results <- forM (buildTestTrees spec) $ \test -> do runTestWith args 0 test let numSucc, numPend, numFail :: Int numSucc = (sum::[Int]->Int) $ map numSuccesses results numPend = (sum::[Int]->Int) $ map numPending results numFail = (sum::[Int]->Int) $ map numFailures results+ endTime <- getCurrentTime when ((numPend + numFail) /= 0) $ putStrLn "\n ----- Failures and pending:\n" forM_ (filterPendingAndFails results) $ \x -> do printAllTestResults 0 x putStrLn ""- putStrLn "\n -----\n"+ putStrLn $ "\n -----\nRuntime: " ++ show (diffUTCTime endTime startTime) let colorF :: String -> String colorF = case (numSucc, numPend, numFail) of (_, 0, 0) -> inGreen@@ -157,7 +160,7 @@ TestLeaf testLabel (Right result) -> do putStrLn $ showResult (labelStr testLabel) result TestLeaf testLabel (Left Pending) -> do- putStrLn $ inYellow (labelStr testLabel ++ " - PENDING")+ putStrLn $ inYellow (labelStr testLabel) ++ " - " ++ inYellow "PENDING" TestBranch testLabel _ -> do putStrLn $ labelStr testLabel where@@ -167,12 +170,13 @@ showResult :: String -> QC.Result -> String showResult testLabel = \case -- note: if we wanted to show quickcheck labels, this is where we would:- Success _ _ _ ->+ Success {} -> inGreen testLabel failure@(Failure{theException=Nothing}) ->- inRed (testLabel ++ " - "++replaceNewline (output failure))+ inRed testLabel ++ " - "++inRed (replaceNewline (output failure)) failure {- @(Failure{}) -} ->- inRed (testLabel ++" - "++replaceNewline (output failure))+ inRed testLabel ++" - "++inRed (replaceNewline (output failure))+ replaceNewline :: String -> String replaceNewline = concatMap $ \case '\n' -> " | " ; x -> [x] labelStr :: String -> String labelStr s = case filter (not . isSpace) s of
microspec.cabal view
@@ -1,5 +1,5 @@ name: microspec-version: 0.2.0.0+version: 0.2.0.1 synopsis: Tiny QuickCheck test library with minimal dependencies description: A tiny (1 module, <500 lines) property-based (and unit) testing library with minimal dependencies.@@ -9,6 +9,8 @@ Instead of reinventing the wheel (<https://xkcd.com/927>), we use a RSpec/HSpec-like API and run tests with QuickCheck. .+ For simple use-cases, microspec is a drop-in replacement for hspec.+ . > import Test.Microspec > > main :: IO ()@@ -51,6 +53,7 @@ -- base >=4.9 && <5 -- , QuickCheck >=2.9 && <2.10 base <5+ , time , QuickCheck -- hs-source-dirs: default-language: Haskell2010