J'écris un test pour une fonction de recherche binaire que j'ai écrite.Comment utiliser quickcheck dans
module Tests where
import Data.List (sort)
import Test.QuickCheck
import BinarySearch (binarySearch)
prop_equals_elem x xs = (binarySearch x $ sort xs) == (x `elem` xs)
args = Args {replay = Nothing, maxSuccess = 200, maxDiscard=200, maxSize=200, chatty = False}
main = do
quickCheck (prop_equals_elem :: (Ord a) => a -> [a] -> Bool)
Il fonctionne bien à l'aide quickcheck en ghci mais quand je tente d'exécuter principal, il donne l'erreur
Tests.hs:12:5:
Ambiguous type variable `a0' in the constraints:
(Arbitrary a0) arising from a use of `quickCheckWith'
at Tests.hs:12:5-18
(Show a0) arising from a use of `quickCheckWith'
at Tests.hs:12:5-18
(Ord a0) arising from an expression type signature
at Tests.hs:12:26-72
Pourquoi ça marche pas mais fait dans ghci?
Pensez également à utiliser http://hackage.haskell.org/package/test-framework – alternative