0

I'm very new to QuickCheck. I know how to write QuickCheck properties like :

prop_rev_involutive l = (reverse $ reverse l) == l

that test the reverse function.

But now I need to write a QuickCheck property with this signature

prop_fastShuffle_correct :: [Int] -> Property
prop_fastShuffle_correct s = undefined 

That suppose to test a fastShuffle function I wrote with this signature :

fastShuffle :: [a] -> IO [a]

I know exactly what I want to test but not sure how the signature

 [Int] -> Property

should impact my code. I assume that my prop_fastShuffle_correct function gets a randomly generated array of integers but I don't understand what it means to return a value from type Property and how to do it.

Hope that someone can give me some guide.

Thanks!

Tomer
  • 1,159
  • 7
  • 15
  • It'll be easier if you write your System Under Test (SUT) as a pure function. See https://stackoverflow.com/a/46791854/126014 for some hints for doing that and using QuickCheck for property-based testing with randomness. – Mark Seemann Mar 04 '20 at 06:53
  • If you truly *must* test a function that returns `IO a`, you can use `ioProperty` or `idempotentIOProperty`. – Mark Seemann Mar 04 '20 at 07:00
  • I'm trying to use monadicIO to test my function that returns IO and I think it is working! – Tomer Mar 04 '20 at 07:14

0 Answers0