summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomanCheplyaka <>2018-01-12 17:17:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-01-12 17:17:00 (GMT)
commit306518406638ee533e9f5b6a1e33bc5492296e6a (patch)
tree45f44fbb58e446267821bd95df06ced48a5b7d51
parent014086764210a019b2ed42215f85e02282aac399 (diff)
version 0.9.20.9.2
-rw-r--r--CHANGELOG.md6
-rw-r--r--Test/Tasty/QuickCheck.hs22
-rw-r--r--tasty-quickcheck.cabal10
-rw-r--r--tests/test.hs5
4 files changed, 34 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9736b97..12a69b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,12 @@
Changes
=======
+Version 0.9.2
+-------------
+
+* Add a `testProperties` function, which allows to test all QuickCheck
+ properties defined in a module.
+
Version 0.9.1
-------------
diff --git a/Test/Tasty/QuickCheck.hs b/Test/Tasty/QuickCheck.hs
index 2c7210c..8d7f94c 100644
--- a/Test/Tasty/QuickCheck.hs
+++ b/Test/Tasty/QuickCheck.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
module Test.Tasty.QuickCheck
( testProperty
+ , testProperties
, QuickCheckTests(..)
, QuickCheckReplay(..)
, QuickCheckShowReplay(..)
@@ -17,6 +18,7 @@ module Test.Tasty.QuickCheck
, optionSetToArgs
) where
+import Test.Tasty ( testGroup )
import Test.Tasty.Providers
import Test.Tasty.Options
import qualified Test.QuickCheck as QC
@@ -37,13 +39,15 @@ import Test.QuickCheck hiding -- for re-export
)
import Data.Typeable
-import Data.Proxy
import Data.List
-import Data.Monoid
import Text.Printf
-import Control.Applicative
-import Test.QuickCheck.Random (QCGen, mkQCGen)
+import Test.QuickCheck.Random (mkQCGen)
import System.Random (getStdRandom, randomR)
+#if !MIN_VERSION_base(4,8,0)
+import Control.Applicative
+import Data.Monoid
+import Data.Proxy
+#endif
newtype QC = QC QC.Property
deriving Typeable
@@ -52,6 +56,14 @@ newtype QC = QC QC.Property
testProperty :: QC.Testable a => TestName -> a -> TestTree
testProperty name prop = singleTest name $ QC $ QC.property prop
+-- | Create a test from a list of QuickCheck properties. To be used
+-- with 'Test.QuickCheck.allProperties'. E.g.
+--
+-- >tests :: TestTree
+-- >tests = testProperties "Foo" $allProperties
+testProperties :: TestName -> [(String, Property)] -> TestTree
+testProperties name = testGroup name . map (uncurry testProperty)
+
-- | Number of test cases for QuickCheck to generate
newtype QuickCheckTests = QuickCheckTests Int
deriving (Num, Ord, Eq, Real, Enum, Integral, Typeable)
@@ -154,7 +166,7 @@ instance IsTest QC where
, Option (Proxy :: Proxy QuickCheckVerbose)
]
- run opts (QC prop) yieldProgress = do
+ run opts (QC prop) _yieldProgress = do
(replaySeed, args) <- optionSetToArgs opts
let
diff --git a/tasty-quickcheck.cabal b/tasty-quickcheck.cabal
index 6f09045..ce4cb28 100644
--- a/tasty-quickcheck.cabal
+++ b/tasty-quickcheck.cabal
@@ -2,7 +2,7 @@
-- documentation, see http://haskell.org/cabal/users-guide/
name: tasty-quickcheck
-version: 0.9.1
+version: 0.9.2
synopsis: QuickCheck support for the Tasty test framework.
description: QuickCheck support for the Tasty test framework.
license: MIT
@@ -10,7 +10,7 @@ license-file: LICENSE
author: Roman Cheplyaka <roma@ro-che.info>
maintainer: Roman Cheplyaka <roma@ro-che.info>
-- copyright:
-homepage: http://documentup.com/feuerbach/tasty
+homepage: https://github.com/feuerbach/tasty
bug-reports: https://github.com/feuerbach/tasty/issues
category: Testing
build-type: Simple
@@ -30,10 +30,13 @@ library
-- hs-source-dirs:
default-language: Haskell2010
+ default-extensions: CPP
+ ghc-options: -Wall
test-suite test
default-language:
Haskell2010
+ default-extensions: CPP
type:
exitcode-stdio-1.0
hs-source-dirs:
@@ -42,7 +45,8 @@ test-suite test
test.hs
build-depends:
base >= 4 && < 5
- , tasty >= 0.10
+ , tasty >= 0.11.1
, tasty-quickcheck
, tasty-hunit
, pcre-light
+ ghc-options: -Wall
diff --git a/tests/test.hs b/tests/test.hs
index 3b1e7ed..f1a23f7 100644
--- a/tests/test.hs
+++ b/tests/test.hs
@@ -5,10 +5,12 @@ import Test.Tasty.Providers as Tasty
import Test.Tasty.Runners as Tasty
import Test.Tasty.QuickCheck
import Test.Tasty.HUnit
-import Data.Monoid
import Data.Maybe
import Text.Regex.PCRE.Light.Char8
import Text.Printf
+#if !MIN_VERSION_base(4,8,0)
+import Data.Monoid (mempty)
+#endif
(=~), (!~)
:: String -- ^ text
@@ -34,6 +36,7 @@ match' text regexStr =
in
isJust $ match regex text []
+main :: IO ()
main =
defaultMain $
testGroup "Unit tests for Test.Tasty.QuickCheck"