Port all the QuickChecks!

Check out our ports for the amazing QuickCheck unit test framework. Gravy, we've got a lot of ports. We currently maintain QuickCheck for six programming languages, and we're working on ports for four more. Interested in porting QuickCheck to your favorite programming language?

We suggest you start by reading the code from node-quickcheck, one of the most readable ports with friendly, familiar C-style syntax.

The beginnings of a QuickCheck port include:

Once you build these two functions, you can test for_all for things like is_odd(int) and multiple_of_two(int). Write your own properties, and see if they hold true for all integers.

QuickCheck doesn't end there. The next few steps:

The last bit is tricky, because in most languages, it's hard to write for_all(). You'll need to master lambdas, so that you can pass and accept properties and generators, and you'll need to dig around in documentation to find an apply(function, arguments[]) function that can pass random values to properties once you've generated the values. If you can't find such a function, you can try to make one, or require all properties to manually extract their arguments from a list. qc, the C port, does this.

Don't forget to test, test, test, QuickCheck itself! A buggy test framework is no help at all. Finally, you may not have to port QuickCheck yourself, odds are there's a decent port available for you at Wikipedia. But what's the fun in that?