fscheck

In FsCheck, how to generate a test record with non-negative fields?

守給你的承諾、 提交于 2019-11-29 14:12:14
In F#, I have a record with a few fields: type myRecord = { a:float; b:float; c:float } I am using FsCheck to test some properties which use this record. For (a contrived) example, let verify_this_property (r:myRecord) = myFunction(r) = (r.a * r.b) / r.c Due to the internal implementation restrictions of myFunction , I would like to have FsCheck create test cases in which each of the fields a,b,c are restricted to non-negative floats. I suspect this requires creating a generator for myRecord , but I have not been able to find any examples of how to do this. Can anyone supply guidance? Try this

In FsCheck, how to generate a test record with non-negative fields?

ぃ、小莉子 提交于 2019-11-28 08:15:42
问题 In F#, I have a record with a few fields: type myRecord = { a:float; b:float; c:float } I am using FsCheck to test some properties which use this record. For (a contrived) example, let verify_this_property (r:myRecord) = myFunction(r) = (r.a * r.b) / r.c Due to the internal implementation restrictions of myFunction , I would like to have FsCheck create test cases in which each of the fields a,b,c are restricted to non-negative floats. I suspect this requires creating a generator for myRecord