Winter 2020 Prospective

:: journal

I’ve decided to make a serious effort this year to start using this blog as a project catalog and public relations vehicle. There should be at least one place on the Internet I can point to as a portfolio that isn’t GitHub. So, in that spirit, here’s what the next few months are starting to look like.

Customizing Source Locations in Rackunit Macros

:: Racket, meta-programming

Generating rackunit tests with Racket macros is an easy way to improve the quality of your unit tests and your unit testing experience. Macros not only save you the time and energy of writing boilerplate, but also allow you to customize how tests are specified.

So what’s the catch?

rackunit’s basic checks are, by and large, functions. They raise run-time errors when they fail, and run-time errors report the source locations of their call sites. In tests generated by purely pattern-based macros, these locations point inside the macro definitions. Giving useful source locations to macro-generated tests takes a little more work.