Monadic QuickCheck测试不适用于任意Repa阵列

时间:2017-04-29 20:56:29

标签: haskell monads quickcheck repa

我正在尝试在Haskell中编写任意Repa阵列的测试。出于某种原因,以下代码段为:

import Test.QuickCheck
import Test.QuickCheck.Monadic
import Data.Array.Repa (Array, DIM2)

prop_id :: Array U DIM2 Double -> Property
prop_id array = monadicIO $ array `R.equalsP` array >>= assert

抛出此异常:

*** Failed! (after 1 test): 
Exception:
Test.QuickCheck.resize: negative size
CallStack (from HasCallStack):
    error, called at ./Test/QuickCheck/Gen.hs:82:22 in QuickCheck-2.9.2-Jyj4gc4JxkEIgGFLAsGhs9:Test.QuickCheck.Gen
Exception thrown while printing test case:
Test.QuickCheck.resize: negative size
CallStack (from HasCallStack):
    error, called at ./Test/QuickCheck/Gen.hs:82:22 in QuickCheck-2.9.2-Jyj4gc4JxkEIgGFLAsGhs9:Test.QuickCheck.Gen

我不确定如何解释这些信息。谢谢你的帮助。

1 个答案:

答案 0 :(得分:2)

这是repa Arbitrary实例中的一个错误。 arbitrary在大小为0时崩溃。您可以同时修复属性使用的生成器:

quickCheck $ forAll (scale (+1) arbitrary) prop_id