art with code


QuickCheck in make_suite.rb

Adapted from Jane Street Capital's Core to use for testing. Will write a longer post tomorrow (need to be wide awake in 7 hours), but now I can do this:

let shell_escape =
let re = Pcre.regexp "(?=[^a-zA-Z0-9._+/-])" in
Pcre.replace ~rex:re ~templ:"\\"
Q.uint (fun i -> shell_escape (string_of_int i) = (string_of_int i))
Q.string (fun s -> slen (shell_escape s) = slen s)

And get error messages like:

law Q.string (fun s -> slen (shell_escape s) = slen s) failed for

I also tweaked the bool test error messages, now they include the assertion body:

FAIL: Unit tests:0:Prelude unit tests:671:test_prelude_line_8631

OUnit: Line 5 of bool test: shell_escape "foo is fan/cy+some!" = "foo\\ is\\ fan/cy+some!"

Oh and hey, there's an F# port of QuickCheck too.
Post a Comment

Blog Archive

About Me

My photo

Built art installations, web sites, graphics libraries, web browsers, mobile apps, desktop apps, media player themes, many nutty prototypes, much bad code, much bad art.

Have freelanced for Verizon, Google, Mozilla, Warner Bros, Sony Pictures, Yahoo!, Microsoft, Valve Software, TDK Electronics.

Ex-Chrome Developer Relations.