From 9271b7643058f60c3018548b6047f9e4072b3ab5 Mon Sep 17 00:00:00 2001 From: Mads Rolsdorph Date: Sat, 5 Jun 2021 16:25:57 +0200 Subject: [PATCH 1/2] Restore verboseBatch functionality Looks like verboseBatch has just been another name for quickBatch for quite some time! I believe QuickChecks verboseCheckWith should be what we're looking for in order to make it work again. --- checkers.cabal | 2 +- src/Test/QuickCheck/Checkers.hs | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/checkers.cabal b/checkers.cabal index 9013527..c36425a 100644 --- a/checkers.cabal +++ b/checkers.cabal @@ -1,5 +1,5 @@ Name: checkers -Version: 0.5.6 +Version: 0.5.7 Cabal-Version: >= 1.10 Synopsis: Check properties on standard classes and data structures. Category: Testing diff --git a/src/Test/QuickCheck/Checkers.hs b/src/Test/QuickCheck/Checkers.hs index c0e1f0d..90e994c 100644 --- a/src/Test/QuickCheck/Checkers.hs +++ b/src/Test/QuickCheck/Checkers.hs @@ -97,18 +97,21 @@ unbatch :: TestBatch -> [Test] unbatch (batchName,props) = map (first ((batchName ++ ": ")++)) props -- TODO: consider a tree structure so that flattening is unnecessary. +type QuickCheckRunner = Args -> Property -> IO () -- | Run a batch of tests. See 'quickBatch' and 'verboseBatch'. -checkBatch :: Args -> TestBatch -> IO () -checkBatch args (name,tests) = +checkBatch' :: QuickCheckRunner -> Args -> TestBatch -> IO () +checkBatch' runner args (name,tests) = do putStrLn $ "\n" ++ name ++ ":" mapM_ pr tests where pr (s,p) = do putStr (padTo (width + 4) (" "++s ++ ":")) - Ex.catch (quickCheckWith args p) + Ex.catch (runner args p) (print :: Ex.SomeException -> IO ()) width = foldl' max 0 (map (length.fst) tests) +checkBatch :: Args -> TestBatch -> IO () +checkBatch = checkBatch' quickCheckWith padTo :: Int -> String -> String padTo n = take n . (++ repeat ' ') @@ -119,14 +122,10 @@ quickBatch = checkBatch quick' -- | Check a batch verbosely. verboseBatch :: TestBatch -> IO () -verboseBatch = checkBatch verbose' +verboseBatch = checkBatch' verboseCheckWith quick' -quick', verbose' :: Args +quick' :: Args quick' = stdArgs { maxSuccess = 500 } -verbose' = quick' - -- quick' { configEvery = \ n args -> show n ++ ":\n" ++ unlines args } - --- TODO: Restore verbose functionality. How in QC2? {- From e3acb37a407a7f9f91746148c54292979419125d Mon Sep 17 00:00:00 2001 From: Mads Rolsdorph Date: Sun, 6 Jun 2021 12:38:51 +0200 Subject: [PATCH 2/2] Update src/Test/QuickCheck/Checkers.hs Co-authored-by: Simon Jakobi --- src/Test/QuickCheck/Checkers.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Test/QuickCheck/Checkers.hs b/src/Test/QuickCheck/Checkers.hs index 90e994c..016c66d 100644 --- a/src/Test/QuickCheck/Checkers.hs +++ b/src/Test/QuickCheck/Checkers.hs @@ -97,6 +97,7 @@ unbatch :: TestBatch -> [Test] unbatch (batchName,props) = map (first ((batchName ++ ": ")++)) props -- TODO: consider a tree structure so that flattening is unnecessary. + type QuickCheckRunner = Args -> Property -> IO () -- | Run a batch of tests. See 'quickBatch' and 'verboseBatch'.