Skip to content

Commit

Permalink
Restore verboseBatch functionality
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rolsdorph committed Jun 5, 2021
1 parent 6cdc62e commit 9271b76
Show file tree
Hide file tree
Showing 2 changed files with 9 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
17 changes: 8 additions & 9 deletions src/Test/QuickCheck/Checkers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' ')
Expand All @@ -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?

{-
Expand Down

0 comments on commit 9271b76

Please sign in to comment.