I am using QuickCheck
to test the following program:
{-# LANGUAGE TemplateHaskell #-}
import Test.QuickCheck
import Test.QuickCheck.All
elementAt :: (Integral b) => [a] -> b -> a
elementAt [x] _ = x
elementAt (x:xs) 1 = x
elementAt (x:xs) b = elementAt xs (b - 1)
prop_elementAt xs b = length xs > 0 && b >= 0 && b < length xs ==> elementAt xs (b + 1) == xs !! b
main = $(quickCheckAll)
Although the response varies, I constantly receive the message
*** Gave up! Passed only x tests.
Is this something I should be concerned about? Or does the nature of the test input dictate how long QuickCheck will run for?
verboseCheck prop_elementAt
for me returns endless lists consisting only of the element()
, meaning an implementation ofelementAt (x:xs) _ = x
still passes. Any idea on how to generate a list with actual elements in it? – Elvera