Skip to content

Commit

Permalink
Support QuickCheck 2
Browse files Browse the repository at this point in the history
  • Loading branch information
joachifm committed Jan 15, 2010
1 parent 1c7d6b0 commit a5761d4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libmpd.cabal
Expand Up @@ -52,7 +52,7 @@ Library
Executable test
Hs-Source-Dirs: . tests
Main-Is: tests/Main.hs
Build-Depends: base, network, mtl, filepath, utf8-string, QuickCheck < 2
Build-Depends: base, network, mtl, filepath, utf8-string, QuickCheck ==2.1.*
ghc-options: -Wall -Werror -fno-warn-warnings-deprecations

if flag(coverage)
Expand Down
10 changes: 6 additions & 4 deletions tests/Arbitrary.hs
Expand Up @@ -17,6 +17,12 @@ import Test.QuickCheck

import Network.MPD.Commands.Types

-- No longer provided by QuickCheck 2
two :: Monad m => m a -> m (a, a)
two m = liftM2 (,) m m

three :: Monad m => m a -> m (a, a, a)
three m = liftM3 (,,) m m m

-- Generate a positive number.
positive :: (Arbitrary a, Num a) => Gen a
Expand All @@ -26,10 +32,6 @@ positive = abs `fmap` arbitrary
field :: Gen String
field = (filter (/= '\n') . dropWhile isSpace) `fmap` arbitrary


instance Arbitrary Char where
arbitrary = choose ('\0', '\128')

-- an assoc. string is a string of the form "key: value", followed by
-- the key and value separately.
data AssocString = AS String String String
Expand Down
2 changes: 1 addition & 1 deletion tests/Commands.hs
Expand Up @@ -119,7 +119,7 @@ test_ :: [(Expect, Response String)] -> StringMPD () -> IO ()
test_ a b = test a (Right ()) b

mycheck :: QC.Testable a => a -> Int -> IO ()
mycheck a n = QC.check QC.defaultConfig { QC.configMaxTest = n } a
mycheck a n = QC.quickCheckWith QC.stdArgs { QC.maxSize = n } a

showResult :: Show a => Result a -> String
showResult Ok =
Expand Down
3 changes: 1 addition & 2 deletions tests/Properties.hs
Expand Up @@ -9,7 +9,6 @@ import Network.MPD.Commands.Types
import Network.MPD.Utils

import Control.Monad
import Data.Char
import Data.List
import Data.Maybe
import System.Environment
Expand Down Expand Up @@ -41,7 +40,7 @@ main = do
,("parseStats", mytest prop_parseStats)]

mytest :: Testable a => a -> Int -> IO ()
mytest a n = check defaultConfig { configMaxTest = n } a
mytest a n = quickCheckWith stdArgs { maxSize = n } a

prop_parseDate_simple :: YearString -> Bool
prop_parseDate_simple (YS x) = isJust $ parseDate x
Expand Down

0 comments on commit a5761d4

Please sign in to comment.