I am using Haskell and QuickCheck to write a test for the following function:
{-| Given a list of points and a direction, find the point furthest
along in that direction. -}
fn :: (Eq a, Ord a, DotProd a) => [a] -> a -> a
fn pnts dir = pnts !! index
where index = fromJust $ elemIndex (maximum dotproducts) dotproducts
dotproducts = map (dot dir) pnts
I believe this implementation to be correct, since it's not too complex of a function. But, I want to use QuickCheck to test it for some edge cases.
However, I run into the problem that, when I define my QuickCheck tests, they are identical to the function I am testing.
How do I write a test in QuickCheck that tests the purpose of a function without repeating its implementation?