Skip to content

Commit

Permalink
add prop shortcut back
Browse files Browse the repository at this point in the history
  • Loading branch information
gregwebs committed May 21, 2011
1 parent 23d1325 commit 070205f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Test/Hspec/Monadic.hs
Expand Up @@ -69,7 +69,10 @@ module Test.Hspec.Monadic (
-- the main api
describe, it, hspec, pending, descriptions,
-- alternate "runner" functions
hHspec
hHspec,
-- this is just for internal use
ItSpec

) where

import System.IO
Expand Down
16 changes: 13 additions & 3 deletions Test/Hspec/QuickCheck.hs
Expand Up @@ -13,21 +13,31 @@
-- > ]
--
module Test.Hspec.QuickCheck (
property
property,
-- shortcut for the Monadic DSL
prop
) where

import System.IO.Silently
import Test.Hspec.Core
import qualified Test.QuickCheck as QC

-- just for the prop shortcut
import qualified Test.Hspec.Monadic as DSL
import Control.Monad.Trans.Writer (Writer)

data QuickCheckProperty a = QuickCheckProperty a

property :: QC.Testable a => a -> QuickCheckProperty a
property = QuickCheckProperty

-- | Monadic DSL shortcut, use this instead of @it@
prop :: QC.Testable t => String -> t -> Writer [DSL.ItSpec] ()
prop n p = DSL.it n (QuickCheckProperty p)

instance QC.Testable t => SpecVerifier (QuickCheckProperty t) where
it description (QuickCheckProperty prop) = do
r <- silence $ QC.quickCheckResult prop
it description (QuickCheckProperty p) = do
r <- silence $ QC.quickCheckResult p
let r' = case r of
QC.Success {} -> Success
f@(QC.Failure {}) -> Fail (QC.output f)
Expand Down

0 comments on commit 070205f

Please sign in to comment.