How to get Haskell QuickCheck 2.4 to increase # te

2019-02-05 15:07发布

Okay, as I learned via my previous question, the RWH book is already out of date for QuickCheck. And despite all the posts I've read that tell me how incredibly simple it is to use QuickCheck, I cannot find any place that tells me how to change the number of tests to run for a property.

RWH says:

handyCheck limit = check defaultConfig {
                     configMaxTest = limit
                   , configEvery   = \_ _ -> ""
                   }

How to do this with QuickCheck 2.4? More importantly, how would I have found out myself? Please don't tell me that I should've been able to figure it out from the API documentation.

2条回答
冷血范
2楼-- · 2019-02-05 15:38

For those who want to run all tests at once and provide their configuration:

return []
main = $forAllProperties (quickCheckWithResult stdArgs { maxSuccess = 500 })
查看更多
一纸荒年 Trace。
3楼-- · 2019-02-05 15:39

You are looking for:

quickCheckWith stdArgs { maxSuccess = 5000 } someProp

How I found out

  1. I went to the API documentation.
  2. The 2nd thing I saw, after quickCheck was the Args type with a maxSuccess field.
  3. I didn't want to write all the fields, so I looked for a value of type Args - finding stdArgs. (Use your browsers search function - ctrl-f usually). OTOH, I could have used hoogle.
  4. I needed to use my Args type somewhere so I kept looking. The next line was quickCheckWith - bingo! On the other hand, I could have used hoogle.

How Else Can You Find Out

As I stated above, you could have used hoogle to find a lot of the functions, assuming you realize the Args type is the core of what you need (from the haddocks).

Otherwise, you are probably reduced to looking at what other packages do, which means you need to know what other packages are worth looking at. The examples folder in QuickCheck seems obvious, but not all packages include such examples. Using reverse dependencies you can often find a package to look at, but for QC lots of packages don't have explicit dependencies.

查看更多
登录 后发表回答