quickCheckAll always return “True”

后端 未结 2 517
误落风尘
误落风尘 2021-01-12 07:37

I\'m trying to use QuickCheck following another answer. I test like this:

{-# LANGUAGE TemplateHaskell #-}
import Test.QuickCheck
import Test.QuickCheck.All

         


        
相关标签:
2条回答
  • 2021-01-12 08:06

    From the Test.QuickCheck.All docs:

    To use quickCheckAll, add a definition to your module along the lines of

    return []
    runTests = $quickCheckAll
    

    and then execute runTests.

    Note: the bizarre return [] in the example above is needed on GHC 7.8; without it, quickCheckAll will not be able to find any of the properties.

    Adding return [] before your check makes it work for me.

    0 讨论(0)
  • 2021-01-12 08:14

    To use quickCheckAll, you need a function which reads:

    return [] runTests = $quickCheckAll

    The other comment mentions this, but doesn't point out that it will still always return true unless the function is located below all of your quickCheck functions!

    0 讨论(0)
提交回复
热议问题