Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianAlgehed committed Apr 18, 2024
1 parent fdfa60c commit e37cfc5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/Test/QuickCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ module Test.QuickCheck
, quickCheckWithResult
, quickCheckResult
#ifndef NO_TYPEABLE
, quickCheckWitness
, quickCheckWithWitness
, quickCheckWitnesses
, quickCheckWithWitnesses
#endif
, recheck
, isSuccess
Expand Down
2 changes: 1 addition & 1 deletion src/Test/QuickCheck/Property.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
20 changes: 10 additions & 10 deletions src/Test/QuickCheck/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e37cfc5

Please sign in to comment.