test-framework-quickcheck2-0.3.0.5/0000755000000000000000000000000013343265164015216 5ustar0000000000000000test-framework-quickcheck2-0.3.0.5/LICENSE0000644000000000000000000000276613343265164016236 0ustar0000000000000000Copyright (c) 2008, Maximilian Bolingbroke All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Maximilian Bolingbroke nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.test-framework-quickcheck2-0.3.0.5/Setup.hs0000644000000000000000000000005613343265164016653 0ustar0000000000000000import Distribution.Simple main = defaultMain test-framework-quickcheck2-0.3.0.5/test-framework-quickcheck2.cabal0000644000000000000000000000336413343265164023354 0ustar0000000000000000Cabal-Version: >= 1.10 Name: test-framework-quickcheck2 Version: 0.3.0.5 Category: Testing Synopsis: QuickCheck-2 support for the test-framework package. License: BSD3 License-File: LICENSE Author: Max Bolingbroke Maintainer: Haskell Libraries Homepage: http://haskell.github.io/test-framework/ Bug-Reports: https://github.com/haskell/test-framework/issues Build-Type: Simple Description: Allows @QuickCheck-2@ properties to be used with the . Tested-With: GHC==8.4.1, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2, GHC==7.0.4 extra-source-files: ChangeLog.md Library Default-Language: Haskell2010 Other-Extensions: CPP DeriveDataTypeable ExistentialQuantification MultiParamTypeClasses TypeOperators TypeSynonymInstances Exposed-Modules: Test.Framework.Providers.QuickCheck2 Build-Depends: test-framework == 0.8.* , QuickCheck >= 2.4 && < 2.13 , base >= 4.3 && < 5 , extensible-exceptions >= 0.1.1 && < 0.2.0 , random >= 1 && < 1.2 Ghc-Options: -Wall Source-Repository head Type: git Location: https://github.com/haskell/test-framework.git subdir: quickcheck2 test-framework-quickcheck2-0.3.0.5/ChangeLog.md0000644000000000000000000000040013343265164017361 0ustar0000000000000000## 0.3.0.5 - Add support for `QuickCheck-2.12` ## 0.3.0.4 - Add support for `Quickcheck >= 2.8 && < 2.11`'s `InsufficientCoverage` status result - Drop support for GHC < 7.0 (require `Haskell2010` support) - Prevent `maxDiscardRatio` from becoming zero test-framework-quickcheck2-0.3.0.5/Test/0000755000000000000000000000000013343265164016135 5ustar0000000000000000test-framework-quickcheck2-0.3.0.5/Test/Framework/0000755000000000000000000000000013343265164020072 5ustar0000000000000000test-framework-quickcheck2-0.3.0.5/Test/Framework/Providers/0000755000000000000000000000000013343265164022047 5ustar0000000000000000test-framework-quickcheck2-0.3.0.5/Test/Framework/Providers/QuickCheck2.hs0000644000000000000000000001425313343265164024504 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeSynonymInstances #-} -- | Allows QuickCheck2 properties to be used with the test-framework package. -- -- For an example of how to use @test-framework@, please see . module Test.Framework.Providers.QuickCheck2 ( testProperty ) where import Test.Framework.Providers.API import Test.QuickCheck.Property (Testable, Callback(PostTest), CallbackKind(NotCounterexample), callback) import Test.QuickCheck.State (numSuccessTests) import Test.QuickCheck.Test #if MIN_VERSION_QuickCheck(2,7,0) import Test.QuickCheck.Random (QCGen, mkQCGen) #endif import System.Random import Data.Typeable -- | Create a 'Test' for a QuickCheck2 'Testable' property testProperty :: Testable a => TestName -> a -> Test testProperty name = Test name . Property instance TestResultlike PropertyTestCount PropertyResult where testSucceeded = propertySucceeded -- | Used to document numbers which we expect to be intermediate test counts from running properties type PropertyTestCount = Int -- | The failure information from the run of a property data PropertyResult = PropertyResult { pr_status :: PropertyStatus, pr_used_seed :: Int, pr_tests_run :: Maybe PropertyTestCount -- Due to technical limitations, it's currently not possible to find out the number of -- tests previously run if the test times out, hence we need a Maybe here for that case. } data PropertyStatus = PropertyOK -- ^ The property is true as far as we could check it | PropertyArgumentsExhausted -- ^ The property may be true, but we ran out of arguments to try it out on | PropertyFalsifiable String String -- ^ The property was not true. The strings are the reason and the output. | PropertyNoExpectedFailure -- ^ We expected that a property would fail but it didn't | PropertyTimedOut -- ^ The property timed out during execution #if MIN_VERSION_QuickCheck(2,8,0) && !MIN_VERSION_QuickCheck(2,12,0) | PropertyInsufficientCoverage -- ^ The tests passed but a use of 'cover' had insufficient coverage. #endif instance Show PropertyResult where show (PropertyResult { pr_status = status, pr_used_seed = used_seed, pr_tests_run = mb_tests_run }) = case status of PropertyOK -> "OK, passed " ++ tests_run_str ++ " tests" PropertyArgumentsExhausted -> "Arguments exhausted after " ++ tests_run_str ++ " tests" PropertyFalsifiable _rsn otpt -> otpt ++ "(used seed " ++ show used_seed ++ ")" PropertyNoExpectedFailure -> "No expected failure with seed " ++ show used_seed ++ ", after " ++ tests_run_str ++ " tests" PropertyTimedOut -> "Timed out after " ++ tests_run_str ++ " tests" #if MIN_VERSION_QuickCheck(2,8,0) && !MIN_VERSION_QuickCheck(2,12,0) PropertyInsufficientCoverage -> "Insufficient coverage after " ++ tests_run_str ++ " tests" #endif where tests_run_str = fmap show mb_tests_run `orElse` "an unknown number of" propertySucceeded :: PropertyResult -> Bool propertySucceeded (PropertyResult { pr_status = status, pr_tests_run = mb_n }) = case status of PropertyOK -> True PropertyArgumentsExhausted -> maybe False (/= 0) mb_n _ -> False data Property = forall a. Testable a => Property a deriving Typeable instance Testlike PropertyTestCount PropertyResult Property where runTest topts (Property testable) = runProperty topts testable testTypeName _ = "Properties" #if MIN_VERSION_QuickCheck(2,7,0) newSeededQCGen :: Seed -> IO (QCGen, Int) newSeededQCGen (FixedSeed seed) = return $ (mkQCGen seed, seed) newSeededQCGen RandomSeed = do seed <- randomIO return (mkQCGen seed, seed) #else newSeededQCGen :: Seed -> IO (StdGen, Int) newSeededQCGen = newSeededStdGen #endif runProperty :: Testable a => CompleteTestOptions -> a -> IO (PropertyTestCount :~> PropertyResult, IO ()) runProperty topts testable = do (gen, seed) <- newSeededQCGen (unK $ topt_seed topts) let max_success = unK $ topt_maximum_generated_tests topts max_discard = unK $ topt_maximum_unsuitable_generated_tests topts args = stdArgs { replay = Just (gen, 0) -- NB: the 0 is the saved size. Defaults to 0 if you supply "Nothing" for "replay". , maxSuccess = max_success #if MIN_VERSION_QuickCheck(2,5,0) , maxDiscardRatio = (max_discard `div` max_success) + 1 #else , maxDiscard = max_discard #endif , maxSize = unK $ topt_maximum_test_size topts , chatty = False } -- FIXME: yield gradual improvement after each test runImprovingIO $ do tunnel <- tunnelImprovingIO mb_result <- maybeTimeoutImprovingIO (unK (topt_timeout topts)) $ liftIO $ quickCheckWithResult args (callback (PostTest NotCounterexample (\s _r -> tunnel $ yieldImprovement $ numSuccessTests s)) testable) return $ case mb_result of Nothing -> PropertyResult { pr_status = PropertyTimedOut, pr_used_seed = seed, pr_tests_run = Nothing } Just result -> PropertyResult { pr_status = toPropertyStatus result, pr_used_seed = seed, pr_tests_run = Just (numTests result) } where toPropertyStatus (Success {}) = PropertyOK toPropertyStatus (GaveUp {}) = PropertyArgumentsExhausted toPropertyStatus (Failure { reason = rsn, output = otpt }) = PropertyFalsifiable rsn otpt toPropertyStatus (NoExpectedFailure {}) = PropertyNoExpectedFailure #if MIN_VERSION_QuickCheck(2,8,0) && !MIN_VERSION_QuickCheck(2,12,0) toPropertyStatus (InsufficientCoverage _ _ _) = PropertyInsufficientCoverage #endif