Download Goanna Static Analysis by Red Lizard Software

Posts Tagged ‘testing’

CamlP4 for unit testing

We’ve been mulling over how to add new unit tests to our OCaml codebase. Our first thought was to write a test suite apart from the code itself; we’ve already some end-to-end tests written in that way. The problem with that approach is that the tests are separated from the code they’re testing, which discourages writing tests.

A few weeks ago, we wrote some time- and heap-profiling CamlP4 macros, which add entries to a centralized table as our code runs. When the program finishes, it spits out statistics that we can examine for time and space sinks. The profiling hints — macros, that is — wrap the code to be profiled. So why not use the same approach for our tests?

(more…)

production