diff --git a/src/Test/QuickCheck.hs b/src/Test/QuickCheck.hs index e79499c6..1ea6e881 100644 --- a/src/Test/QuickCheck.hs +++ b/src/Test/QuickCheck.hs @@ -324,7 +324,7 @@ module Test.QuickCheck -- ** What to do on failure #ifndef NO_TYPEABLE , Witness(..) - , withWitness + , witness , coerceWitness , castWitness #endif diff --git a/src/Test/QuickCheck/Property.hs b/src/Test/QuickCheck/Property.hs index a6947b65..354514af 100644 --- a/src/Test/QuickCheck/Property.hs +++ b/src/Test/QuickCheck/Property.hs @@ -256,25 +256,25 @@ data CallbackKind = Counterexample -- ^ Affected by the 'verbose' combinator | NotCounterexample -- ^ Not affected by the 'verbose' combinator #ifndef NO_TYPEABLE -data Witness = forall a. (Typeable a, Show a) => Cex a +data Witness = forall a. (Typeable a, Show a) => Wit a instance Show Witness where - show (Cex a) = show a + show (Wit a) = show a coerceWitness :: Typeable a => Witness -> a -coerceWitness (Cex a) = case cast a of +coerceWitness (Wit a) = case cast a of Nothing -> error $ "Can't coerceWitness " ++ show a Just a -> a castWitness :: Typeable a => Witness -> Maybe a -castWitness (Cex a) = cast a +castWitness (Wit a) = cast a data Witnesses = NoWitnesses | forall a. (Typeable a, Show a) => a :! Witnesses toWitnesses :: [Witness] -> Witnesses toWitnesses [] = NoWitnesses -toWitnesses (Cex a : ces) = a :! toWitnesses ces +toWitnesses (Wit a : ces) = a :! toWitnesses ces #define WITNESSES(a) , theWitnesses a #else @@ -534,8 +534,8 @@ 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. -withWitness :: (Typeable a, Show a, Testable prop) => a -> prop -> Property -withWitness a = a `seq` mapTotalResult (\res -> res{ theWitnesses = Cex a : theWitnesses res }) +witness :: (Typeable a, Show a, Testable prop) => a -> prop -> Property +witness a = a `seq` mapTotalResult (\res -> res{ theWitnesses = Wit a : theWitnesses res }) #endif -- | Check that all coverage requirements defined by 'cover' and 'coverTable' diff --git a/src/Test/QuickCheck/Test.hs b/src/Test/QuickCheck/Test.hs index e45d1e05..aa238726 100644 --- a/src/Test/QuickCheck/Test.hs +++ b/src/Test/QuickCheck/Test.hs @@ -146,7 +146,7 @@ data Result -- ^ The test case's classes (see 'classify') #ifndef NO_TYPEABLE , witnesses :: [Witness] - -- ^ The existentially quantified witnesses provided by 'withWitness' + -- ^ The existentially quantified witnesses provided by 'witness' #endif } -- | A property that should have failed did not @@ -207,7 +207,7 @@ quickCheckWithResult a p = -- | Test a property and get witnesses as a result. Can be used like: -- -- @ --- $> x :! _ <- quickCheckWitnesses $ \ x -> withWitness (x :: Int) (x > 0) +-- $> x :! _ <- quickCheckWitnesses $ \ x -> witness (x :: Int) (x > 0) -- *** Failed! Falsified (after 1 test): -- 0 -- $> x