chell-quickcheck-0.2.5.2/Test/0000755000000000000000000000000013432110071014152 5ustar0000000000000000chell-quickcheck-0.2.5.2/Test/Chell/0000755000000000000000000000000013432130174015207 5ustar0000000000000000chell-quickcheck-0.2.5.2/Test/Chell/QuickCheck.hs0000644000000000000000000001056213432130174017561 0ustar0000000000000000{-# LANGUAGE CPP #-} module Test.Chell.QuickCheck ( property ) where import Data.Monoid (mempty) import System.Random (mkStdGen) import qualified Test.Chell as Chell import qualified Test.QuickCheck as QuickCheck import qualified Test.QuickCheck.Gen as Gen #if MIN_VERSION_QuickCheck(2,7,0) import Test.QuickCheck.Property (unProperty) import qualified Test.QuickCheck.Random as QCRandom #endif import qualified Test.QuickCheck.State as State import qualified Test.QuickCheck.Test as Test import qualified Test.QuickCheck.Text as Text -- | Convert a QuickCheck property to a Chell 'Chell.Test'. -- -- @ --import Test.Chell --import Test.Chell.QuickCheck --import Test.QuickCheck hiding (property) -- --test_NullLength :: Test --test_NullLength = property \"null-length\" -- (\xs -> not (null xs) ==> length xs > 0) -- @ property :: QuickCheck.Testable prop => String -> prop -> Chell.Test #if MIN_VERSION_QuickCheck(2,6,0) property name prop = Chell.test name $ \opts -> Text.withNullTerminal $ \term -> do #else property name prop = Chell.test name $ \opts -> do term <- Text.newNullTerminal #endif let seed = Chell.testOptionSeed opts args = QuickCheck.stdArgs state = State.MkState { State.terminal = term , State.maxSuccessTests = QuickCheck.maxSuccess args #if MIN_VERSION_QuickCheck(2,10,1) , State.maxDiscardedRatio = QuickCheck.maxDiscardRatio args #else , State.maxDiscardedTests = maxDiscardedTests args prop #endif , State.computeSize = computeSize (QuickCheck.maxSize args) (QuickCheck.maxSuccess args) , State.numSuccessTests = 0 , State.numDiscardedTests = 0 #if MIN_VERSION_QuickCheck(2,12,0) , State.classes = mempty , State.tables = mempty , State.requiredCoverage = mempty , State.expected = True , State.coverageConfidence = Nothing #else , State.collected = [] , State.expectedFailure = False #endif #if MIN_VERSION_QuickCheck(2,7,0) , State.randomSeed = QCRandom.mkQCGen seed #else , State.randomSeed = mkStdGen seed #endif , State.numSuccessShrinks = 0 , State.numTryShrinks = 0 #if MIN_VERSION_QuickCheck(2,5,0) , State.numTotTryShrinks = 0 #endif #if MIN_VERSION_QuickCheck(2,5,1) , State.numRecentlyDiscardedTests = 0 #endif #if MIN_VERSION_QuickCheck(2,8,0) , State.labels = mempty #endif #if MIN_VERSION_QuickCheck(2,10,0) , State.numTotMaxShrinks = QuickCheck.maxShrinks args #endif } #if MIN_VERSION_QuickCheck(2,12,0) result <- Test.test state (QuickCheck.property prop) #else #if MIN_VERSION_QuickCheck(2,7,0) let genProp = unProperty (QuickCheck.property prop) #else let genProp = QuickCheck.property prop #endif result <- Test.test state (Gen.unGen genProp) #endif let output = Test.output result notes = [("seed", show seed)] failure = Chell.failure { Chell.failureMessage = output } return $ case result of Test.Success{} -> Chell.TestPassed notes Test.Failure{} -> Chell.TestFailed notes [failure] Test.GaveUp{} -> Chell.TestAborted notes output Test.NoExpectedFailure{} -> Chell.TestFailed notes [failure] -- copied from quickcheck-2.4.1.1/src/Test/QuickCheck/Test.hs computeSize :: Int -> Int -> Int -> Int -> Int computeSize maxSize maxSuccess n d -- e.g. with maxSuccess = 250, maxSize = 100, goes like this: -- 0, 1, 2, ..., 99, 0, 1, 2, ..., 99, 0, 2, 4, ..., 98. | n `roundTo` maxSize + maxSize <= maxSuccess || n >= maxSuccess || maxSuccess `mod` maxSize == 0 = n `mod` maxSize + d `div` 10 | otherwise = (n `mod` maxSize) * maxSize `div` (maxSuccess `mod` maxSize) + d `div` 10 roundTo :: Int -> Int -> Int roundTo n m = (n `div` m) * m maxDiscardedTests :: QuickCheck.Testable prop => QuickCheck.Args -> prop -> Int #if MIN_VERSION_QuickCheck(2,9,0) maxDiscardedTests args _ = QuickCheck.maxDiscardRatio args #elif MIN_VERSION_QuickCheck(2,5,0) maxDiscardedTests args p = if QuickCheck.exhaustive p then QuickCheck.maxDiscardRatio args else QuickCheck.maxDiscardRatio args * QuickCheck.maxSuccess args #else maxDiscardedTests args _ = QuickCheck.maxDiscard args #endif chell-quickcheck-0.2.5.2/license.txt0000644000000000000000000000204113432110071015413 0ustar0000000000000000Copyright (c) 2011 John Millikin 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. chell-quickcheck-0.2.5.2/Setup.hs0000644000000000000000000000005613432110071014670 0ustar0000000000000000import Distribution.Simple main = defaultMain chell-quickcheck-0.2.5.2/chell-quickcheck.cabal0000644000000000000000000000156113432136640017433 0ustar0000000000000000name: chell-quickcheck version: 0.2.5.2 synopsis: QuickCheck support for the Chell testing library category: Testing license: MIT license-file: license.txt author: John Millikin maintainer: Chris Martin, Julie Moronuki build-type: Simple cabal-version: >= 1.6 homepage: https://github.com/typeclasses/chell bug-reports: https://github.com/typeclasses/chell/issues description: QuickCheck support for the testing library. tested-with: GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.3 extra-source-files: changelog.md source-repository head type: git location: https://github.com/typeclasses/chell.git library ghc-options: -Wall build-depends: base >= 4.0 && < 5.0 , chell >= 0.3 && < 0.6 , QuickCheck >= 2.3 && < 2.13 , random exposed-modules: Test.Chell.QuickCheck chell-quickcheck-0.2.5.2/changelog.md0000644000000000000000000000017613432136640015522 0ustar0000000000000000# Release history for `chell-quickcheck` 0.2.5.2 - 2019 Feb 16 * Add support for `QuickCheck` 2.12 0.2.5.1 - 2017 Dec 12