On Wed, Aug 25, 2010 at 17:27, Andrej Mitrovic <andrej.mitrov...@test.com>wrote:

> What would be really cool is if we had a property that returned a random
> value of any integrated type. And for user-defined types, maybe it would
> call a method with a special name. I guess one could make a template
> function that would do just that.
>
>
It reminds me a bit of Haskell's QuickCheck library, used to test code.
http://hackage.haskell.org/package/QuickCheck-2.1.1.1

There is an Arbitrary typeclass that the user defines to generate an
arbitrary value for a given type.
With a D template, it's easy to do that for all numeric types (or, any
'range' type, like char) and arrays / associative arrays. This way,
generating it for classes and struct is easy. The real difficulty would be
to generate an arbitrary function from int function(int), for example.

And, to test, you don't want a perfectly random value: you need the extrema,
degenerate cases like NaN, null pointers, empty arrays, etc.

Philippe

Reply via email to