From 2336786016030ed01d4b2377e0c8ac97921fbd4a Mon Sep 17 00:00:00 2001 From: Maximilian Algehed Date: Thu, 18 Apr 2024 09:42:43 +0200 Subject: [PATCH] react to comments --- src/Test/QuickCheck.hs | 4 ---- src/Test/QuickCheck/Property.hs | 17 ++++++++++------- src/Test/QuickCheck/Test.hs | 17 ----------------- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/Test/QuickCheck.hs b/src/Test/QuickCheck.hs index 1ea6e881..78cbaa1e 100644 --- a/src/Test/QuickCheck.hs +++ b/src/Test/QuickCheck.hs @@ -78,10 +78,6 @@ module Test.QuickCheck , quickCheckWith , quickCheckWithResult , quickCheckResult -#ifndef NO_TYPEABLE - , quickCheckWitnesses - , quickCheckWithWitnesses -#endif , recheck , isSuccess -- ** Running tests verbosely diff --git a/src/Test/QuickCheck/Property.hs b/src/Test/QuickCheck/Property.hs index 354514af..c00f36d5 100644 --- a/src/Test/QuickCheck/Property.hs +++ b/src/Test/QuickCheck/Property.hs @@ -269,13 +269,6 @@ coerceWitness (Wit a) = case cast a of castWitness :: Typeable a => Witness -> Maybe a castWitness (Wit a) = cast a -data Witnesses = NoWitnesses - | forall a. (Typeable a, Show a) => a :! Witnesses - -toWitnesses :: [Witness] -> Witnesses -toWitnesses [] = NoWitnesses -toWitnesses (Wit a : ces) = a :! toWitnesses ces - #define WITNESSES(a) , theWitnesses a #else #define WITNESSES(a) @@ -534,6 +527,16 @@ withMaxSize n = n `seq` mapTotalResult (\res -> res{ maybeMaxTestSize = Just n } #ifndef NO_TYPEABLE -- | Return a value in the 'witnesses' field of the 'Result' returned by 'quickCheckResult'. Witnesses -- are returned outer-most first. +-- +-- In ghci, for example: +-- +-- >>> [Wit x] <- fmap witnesses . quickCheckResult $ \ x -> witness x $ x == (0 :: Int) +-- *** Failed! Falsified (after 2 tests): +-- 1 +-- >>> x +-- 1 +-- >>> :t x +-- x :: Int witness :: (Typeable a, Show a, Testable prop) => a -> prop -> Property witness a = a `seq` mapTotalResult (\res -> res{ theWitnesses = Wit a : theWitnesses res }) #endif diff --git a/src/Test/QuickCheck/Test.hs b/src/Test/QuickCheck/Test.hs index aa238726..7d7c28f9 100644 --- a/src/Test/QuickCheck/Test.hs +++ b/src/Test/QuickCheck/Test.hs @@ -203,23 +203,6 @@ quickCheckWithResult :: Testable prop => Args -> prop -> IO Result quickCheckWithResult a p = withState a (\s -> test s (property p)) -#ifndef NO_TYPEABLE --- | Test a property and get witnesses as a result. Can be used like: --- --- @ --- $> x :! _ <- quickCheckWitnesses $ \ x -> witness (x :: Int) (x > 0) --- *** Failed! Falsified (after 1 test): --- 0 --- $> x --- 0 -quickCheckWitnesses :: Testable prop => prop -> IO Witnesses -quickCheckWitnesses = quickCheckWithWitnesses stdArgs - --- | Test a property, using test arguments, and get witnesses as a result. -quickCheckWithWitnesses :: Testable prop => Args -> prop -> IO Witnesses -quickCheckWithWitnesses args p = toWitnesses . witnesses <$> quickCheckWithResult args p -#endif - -- | Re-run a property with the seed and size that failed in a run of 'quickCheckResult'. recheck :: Testable prop => Result -> prop -> IO () recheck res@Failure{} = quickCheckWith stdArgs{ replay = Just (usedSeed res, usedSize res)} . once