quickcheck-silent-0.11.0.0: src/Test/QuickCheck/Silent.hs
{-# OPTIONS_GHC -Wall -Werror #-}
{-# LANGUAGE NoGeneralizedNewtypeDeriving #-}
{-# LANGUAGE Safe #-}
--------------------------------------------------------------------------------
-- |
-- Copyright : (c) 2026 SPISE MISU ApS
-- License : LGPL-3.0-only
-- Maintainer : SPISE MISU <mail+hackage@spisemisu.com>
-- Stability : experimental
--
-- Testing with QuickCheck in silence
--------------------------------------------------------------------------------
module Test.QuickCheck.Silent
( -- * Property without IO
SilentProp ()
, silent
, Test.QuickCheck.Silent.withNumTests
-- * Running tests
, quickCheckSilent
)
where
--------------------------------------------------------------------------------
import Test.QuickCheck
( Property
, Result
, Testable
, chatty
, property
, quickCheckWithResult
, stdArgs
, withNumTests
)
--------------------------------------------------------------------------------
-- | A `Testable` silent property.
newtype SilentProp = SilentProp { prop :: Property }
--------------------------------------------------------------------------------
-- | Convert a `Testable` thing, without 'System.IO.IO' effects, to a silent
-- property.
silent
:: Testable prop
=> prop
-> SilentProp
silent =
SilentProp . property
-- | Configures how many times a silent property will be tested.
--
-- For example,
--
-- > quickCheckSilent [withNumTests 1000 p]
--
-- will test @p@ up to 1000 times.
withNumTests
:: Testable prop
=> Int
-> prop
-> SilentProp
withNumTests n =
SilentProp . Test.QuickCheck.withNumTests n
--------------------------------------------------------------------------------
-- | Tests a sequence of silent properties, producing a list of results, without
-- printing them to 'System.IO.stdout'.
quickCheckSilent
:: [SilentProp]
-> IO [Result]
quickCheckSilent =
mapM (aux . prop)
where
aux =
quickCheckWithResult $ stdArgs { chatty = False }