Skip to content

Commit

Permalink
Merge pull request #59 from rolsdorph/verbosebatch
Browse files Browse the repository at this point in the history
Restore verboseBatch functionality
  • Loading branch information
conal authored Jun 6, 2021
2 parents 6cdc62e + e3acb37 commit 59de8ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion checkers.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/Test/QuickCheck/Checkers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,21 @@ 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 ' ')
Expand All @@ -119,14 +123,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?

{-
Expand Down

0 comments on commit 59de8ad

Please sign in to comment.