Saturday, May 02, 2009

FsCheck -- a quick hack for bytes

This exceptionally trivial piece of FsCheck:


surprised me by going Microsoft.FSharp.Core.FailureException : Geneflect: type not handled System.Byte. Especially so when the whole thing I was trying to write at the time was all about bytes, in arrays, in queues,...

So a little bit of diving into the FsCheck code later, a quick and dirty extension for handling bytes in Arbitrary.fs:

Later: now with fewer redundant parentheses and other clutter--

which now gives Ok, passed 100 tests. which is what I had been wanting in the first place.

Instrumenting the function under test as

shows a plausibly noisy set of inputs, so any remaining flaws will be subtle ones.

This example is believed to still be correct under the Feb 2010 CTP.

Post a Comment