Closed tomdjong closed 2 years ago
I don't understand why QuickCheck's within is not timing out on infinite lists. To illustrate this, consider the following MWE.
within
import Test.QuickCheck timeout :: Int timeout = 10000 prop_length :: Property prop_length = within timeout $ length (repeat 1) >= 0 repeat' :: a -> [a] repeat' x = take maxBound (repeat x) prop_length' :: Property prop_length' = within timeout $ length (repeat' 1) >= 0
Now quickCheck prop_length' times out as expected, but quickCheck prop_length hangs.
quickCheck prop_length'
quickCheck prop_length
Is this a bug or is there a good reason for this phenomenon?
length and repeat probably compile to a non-allocating loop which base timeout is not able to interrupt.
length
repeat
base
timeout
See
I see, so it's a ghc problem. Thanks a lot for the quick and helpful reply!
ghc
I don't understand why QuickCheck's
within
is not timing out on infinite lists. To illustrate this, consider the following MWE.Now
quickCheck prop_length'
times out as expected, butquickCheck prop_length
hangs.Is this a bug or is there a good reason for this phenomenon?