我正在尝试在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
我不确定如何解释这些信息。谢谢你的帮助。
答案 0 :(得分:2)
这是repa Arbitrary
实例中的一个错误。 arbitrary
在大小为0时崩溃。您可以同时修复属性使用的生成器:
quickCheck $ forAll (scale (+1) arbitrary) prop_id