FsCheck 允许自定义Arbitrary
在其 NUnit 集成中:
[<Property(Verbose = true, Arbitrary= [typeof<Test.Arithmetic.MyArb>])>]
static member MultiplyIdentity (x: int64) = x * 1 = x
这个语法不起作用。我觉得有点不好意思问,但显然我以前从未需要过这个:如何将 F# 中的类型指定为属性参数?微软对此什么也没说 https://learn.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/attributes,也不维基教科书项目 https://en.wikibooks.org/wiki/F_Sharp_Programming/Reflection我在谷歌上搜索这个词时遇到了一些麻烦(这个词type是无所不在的)。
注1:Arbitrary
参数的类型是Type []
.
我想你已经很接近了,但是[1;2;3]
创建一个list<int>
,你想要一个数组文字使用[| 1;2;3 |]
:
[<Property(Verbose = true, Arbitrary= [| typeof<Test.Arithmetic.MyArb> |])>]
static member MultiplyIdentity (x: int64) = x * 1 = x
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)