I've written a complicated function
I'd now like to simplify this function's code, and later enhance it with more features. With each change, however, I'd like to be confident that I'm not breaking previously met specifications. So, I'm looking for a test harness to run between each change.
The obvious, "poor man's" way of doing this seems to be to write a series of
If[...] statements that check a given piece of code against expected output, and
—and automate the testing. (If I were to continue down this route, then of course I'd have to
Hold@ the entire table to prevent cells from executing, and write a function that
Extracts each row in turn, running the expression and checking its return value.)
But, I'm wondering if there's a package in $Mathematica$ built for this purpose, or at least some canonical way of doing things that I should start getting used to, especially if I'm heading toward writing larger and larger pieces of code, maybe even packages and applications, eventually.
Googling Mathematica test harness, I've come across some pages about MUnit, which appear specific to Workbench, which I don't have.
1 In case it'd be helpful to know, my
foo is essentially a data wrapper. Given a symbol, it copies the symbol's OwnValue elsewhere, unsets the symbol, then redefines that symbol with DownValues and UpValues.