{-# LANGUAGE BangPatterns #-} module Test.Common ( testPropertyN, withMaxTimesSuccess, ) where import Control.Applicative ((<|>)) import Test.Hspec (Spec) import Test.Hspec.QuickCheck (prop) import Test.QuickCheck (Property, Testable) import Test.QuickCheck.Property (Result (maybeNumTests), mapTotalResult) withMaxTimesSuccess :: Testable prop => Int -> prop -> Property withMaxTimesSuccess :: forall prop. Testable prop => Int -> prop -> Property withMaxTimesSuccess !Int n = (Result -> Result) -> prop -> Property forall prop. Testable prop => (Result -> Result) -> prop -> Property mapTotalResult ((Result -> Result) -> prop -> Property) -> (Result -> Result) -> prop -> Property forall a b. (a -> b) -> a -> b $ \Result res -> Result res {maybeNumTests = (n *) <$> (maybeNumTests res <|> Just 100)} testPropertyN :: Testable prop => Int -> String -> prop -> Spec testPropertyN :: forall prop. Testable prop => Int -> String -> prop -> Spec testPropertyN Int n String name = String -> Property -> Spec forall prop. (HasCallStack, Testable prop) => String -> prop -> Spec prop String name (Property -> Spec) -> (prop -> Property) -> prop -> Spec forall b c a. (b -> c) -> (a -> b) -> a -> c . Int -> prop -> Property forall prop. Testable prop => Int -> prop -> Property withMaxTimesSuccess Int n