packages feed

tasty-quickcheck (empty) → 0.1

raw patch · 4 files changed

+97/−0 lines, 4 filesdep +QuickCheckdep +basedep +taggedsetup-changed

Dependencies added: QuickCheck, base, tagged, tasty

Files

+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2013 Roman Cheplyaka++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ Test/Tasty/QuickCheck.hs view
@@ -0,0 +1,52 @@+-- | This module allows to use QuickCheck properties in tasty.+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}+module Test.Tasty.QuickCheck+  ( testProperty+  , QuickCheckTests(..)+  ) where++import Test.Tasty.Providers+import Test.Tasty.Options+import qualified Test.QuickCheck as QC+import Data.Typeable+import Data.Proxy+import Text.Printf++newtype QC = QC QC.Property+  deriving Typeable++-- | Create a 'Test' for a SmallCheck 'SC.Testable' property+testProperty :: QC.Testable a => TestName -> a -> TestTree+testProperty name prop = singleTest name $ QC $ QC.property prop++-- | Number of test cases for QuickCheck to generate+newtype QuickCheckTests = QuickCheckTests Int+  deriving (Num, Ord, Eq, Real, Enum, Integral, Typeable)++instance IsOption QuickCheckTests where+  defaultValue = 100+  parseValue = fmap QuickCheckTests . safeRead+  optionName = return "quickcheck-tests"+  optionHelp = return "Number of test cases for QuickCheck to generate"++instance IsTest QC where+  testOptions = return [Option (Proxy :: Proxy QuickCheckTests)]++  run opts (QC prop) yieldProgress = do+    let+      QuickCheckTests nTests = lookupOption opts+      args = QC.stdArgs { QC.chatty = False, QC.maxSuccess = nTests }+    -- TODO yield progress+    r <- QC.quickCheckWithResult args prop+    +    return $ case r of+      QC.Success {} ->+        Result+          { resultSuccessful = True+          , resultDescription = printf "%d tests completed" (QC.numTests r)+          }+      _ ->+        Result+          { resultSuccessful = False+          , resultDescription = QC.output r+          }
+ tasty-quickcheck.cabal view
@@ -0,0 +1,24 @@+-- Initial tasty-quickcheck.cabal generated by cabal init.  For further +-- documentation, see http://haskell.org/cabal/users-guide/++name:                tasty-quickcheck+version:             0.1+synopsis:            QuickCheck support for the Tasty test framework.+description:         QuickCheck support for the Tasty test framework.+license:             MIT+license-file:        LICENSE+author:              Roman Cheplyaka+maintainer:          roma@ro-che.info+-- copyright:           +category:            Testing+build-type:          Simple+-- extra-source-files:  +cabal-version:       >=1.10++library+  exposed-modules:     Test.Tasty.QuickCheck+  -- other-modules:       +  other-extensions:    GeneralizedNewtypeDeriving, DeriveDataTypeable+  build-depends:       base == 4.*, tasty, QuickCheck == 2.*, tagged+  -- hs-source-dirs:      +  default-language:    Haskell2010