What is a shrink, with regard to Haskell's QuickCheck?

后端 未结 2 871
甜味超标
甜味超标 2021-02-01 13:32

I\'m learning the ropes of QuickCheck >= 2.6 but I don\'t understand what a shrink is. From looking at the type signature shrink looks more like expand! Please illuminate me :)<

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 14:11

    A single shrink is a stepwise reduction in complexity of some Arbitrary test case (an "immediate shrink"). This might be something like 2 -> 1 or 1:[] -> []. For more complex types there may be multiple ways to "incrementally shrink" a type so you specify all of them in a list.

    For example, trees might be shrunk by removing any one leaf, thus if there are n leaves then shrink produces a list of length n.

提交回复
热议问题