From e37cfc547844a2789464140307349c13c146172f Mon Sep 17 00:00:00 2001 From: Maximilian Algehed Date: Thu, 4 Apr 2024 10:44:02 +0200 Subject: [PATCH] wip --- src/Test/QuickCheck.hs | 4 ++-- src/Test/QuickCheck/Property.hs | 2 +- src/Test/QuickCheck/Test.hs | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Test/QuickCheck.hs b/src/Test/QuickCheck.hs index 1782d654..e79499c6 100644 --- a/src/Test/QuickCheck.hs +++ b/src/Test/QuickCheck.hs @@ -79,8 +79,8 @@ module Test.QuickCheck , quickCheckWithResult , quickCheckResult #ifndef NO_TYPEABLE - , quickCheckWitness - , quickCheckWithWitness + , quickCheckWitnesses + , quickCheckWithWitnesses #endif , recheck , isSuccess diff --git a/src/Test/QuickCheck/Property.hs b/src/Test/QuickCheck/Property.hs index 75040935..6b14e0b5 100644 --- a/src/Test/QuickCheck/Property.hs +++ b/src/Test/QuickCheck/Property.hs @@ -532,7 +532,7 @@ withMaxSize :: Testable prop => Int -> prop -> Property withMaxSize n = n `seq` mapTotalResult (\res -> res{ maybeMaxTestSize = Just n }) #ifndef NO_TYPEABLE --- | Return a value in the 'counterexamples' field of the 'Result' returned by 'quickCheckResult'. Witnesses +-- | Return a value in the 'witnesses' field of the 'Result' returned by 'quickCheckResult'. Witnesses -- are returned outer-most first. withWitness :: (Typeable a, Show a, Testable prop) => a -> prop -> Property withWitness a = a `seq` mapTotalResult (\res -> res{ theWitnesses = Cex a : theWitnesses res }) diff --git a/src/Test/QuickCheck/Test.hs b/src/Test/QuickCheck/Test.hs index ed90784b..e45d1e05 100644 --- a/src/Test/QuickCheck/Test.hs +++ b/src/Test/QuickCheck/Test.hs @@ -145,8 +145,8 @@ data Result , failingClasses :: Set String -- ^ The test case's classes (see 'classify') #ifndef NO_TYPEABLE - , counterexamples :: [Witness] - -- ^ The existentially quantified counterexamples provided by 'withWitness' + , witnesses :: [Witness] + -- ^ The existentially quantified witnesses provided by 'withWitness' #endif } -- | A property that should have failed did not @@ -204,20 +204,20 @@ quickCheckWithResult a p = withState a (\s -> test s (property p)) #ifndef NO_TYPEABLE --- | Test a property and get counterexamples as a result. Can be used like: +-- | Test a property and get witnesses as a result. Can be used like: -- -- @ --- $> x :! _ <- quickCheckWitness $ \ x -> withWitness (x :: Int) (x > 0) +-- $> x :! _ <- quickCheckWitnesses $ \ x -> withWitness (x :: Int) (x > 0) -- *** Failed! Falsified (after 1 test): -- 0 -- $> x -- 0 -quickCheckWitness :: Testable prop => prop -> IO Witnesses -quickCheckWitness = quickCheckWithWitness stdArgs +quickCheckWitnesses :: Testable prop => prop -> IO Witnesses +quickCheckWitnesses = quickCheckWithWitnesses stdArgs --- | Test a property, using test arguments, and get counterexamples as a result. -quickCheckWithWitness :: Testable prop => Args -> prop -> IO Witnesses -quickCheckWithWitness args p = toWitnesses . counterexamples <$> quickCheckWithResult args p +-- | 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'. @@ -508,7 +508,7 @@ runATest st prop = , failingLabels = P.labels res , failingClasses = Set.fromList (map fst $ filter snd $ P.classes res) #ifndef NO_TYPEABLE - , counterexamples = theWitnesses res + , witnesses = theWitnesses res #endif } where