module Test.Hspec.QuickCheck (
property
) where
import System.IO.Silently
import Test.Hspec.Core
import qualified Test.QuickCheck as QC
data QuickCheckProperty a = QuickCheckProperty a
property :: QC.Testable a => a -> QuickCheckProperty a
property = QuickCheckProperty
instance QC.Testable t => SpecVerifier (QuickCheckProperty t) where
it description (QuickCheckProperty prop) = do
r <- silence $ QC.quickCheckResult prop
let r' = case r of
QC.Success {} -> Success
f@(QC.Failure {}) -> Fail (QC.output f)
g@(QC.GaveUp {}) -> Fail ("Gave up after " ++ quantify (QC.numTests g) "test" )
QC.NoExpectedFailure {} -> Fail ("No expected failure")
return (description, r')