I have a program that takes a list and halves each even number in a list
halfEvens :: [Int] -> [Int]
halfEvens xs = [if x `mod` 2 == 0 then x `div` 2 else x | x <- xs]
and I want to write a quickCheck property for this functions which verifies if the initial and the compiled lists are equal if and only if there's no even number in that list
prop_evens xs = ((halfEvens xs == xs) && (length (filter (even) xs) == 0))
My problem is that this property failed after 3 tests. I have no idea what I'm doing wrong. Is the property I wrote wrong?
That's not what you're testing. You're testing that two properties hold:
However, you want either both of them (
A && B), or none (not (A || B)):Therefore, you would test something like
If you want to use a list of odd numbers for testing use
forAlltogether with the rightGen: