Macro cold_iron::thaumtest[]

macro_rules! thaumtest {
    (success, failure) => { ... };
}
Expand description

Stochastic testing for intent-influenced programming

testing is an essential part of writing good software. Computers are obedient to a fault, and that means well-tested code is much more likely to be correct code.

Thaumatic programming, however, presents a conundrum. Magic, to some extent, cares more about intent than precision. If you think your code is going to work, it likely will. Is testing therefore not needed? Everything should simply work on a first try, no?

Alas, it is not that simple. Even the most confident programmer knows themselves to be fallible, and as a result, mistakes will creep in. Nobody quite understands the mechanism by which intent becomes Direction, but it’s clearly not a perfect system.

Should we then despair? Fortunately, not that either. coldiron has a remarkable solution to this problem: double-blind testing.

Simply put, you write two sets of tests: one that should pass, and one that should never pass. When you run cargo test, it will randomly select one of these sets to run. The test runner itself has no idea which set of tests its running, by design this information is limited to the coldiron runner. It runs each test several times, such that one can be sure both pass and fail suites have been executed at least once. At that point, the only portion of intent for the Direction is that of the code itself, now known to be correct (or incorrect).

For more information, see the examples directory, or the thaumtest! macro below. thaumtest marks a test as thaumaturgic, and therefore needing stoichastic implementation. You should provide two functions, with the same name: One that should always pass, and one that should never pass.