vyrn

Testing and bench

Tests and benchmarks live in the file they are about. vyrn run and vyrn build strip them.

test blocks

A test block sits beside the code it tests. vyrn test <file> runs the blocks and reports each one; --name selects a subset. assert and assertEq exist inside a test block and nowhere else.

A file can hold tests and a main at once. The tests are checked, then stripped, so the program is unchanged by having them.

clamp(5) is 5 clamp(99) is 10

bench blocks

A bench block is a body the timer runs. vyrn bench reports the minimum, median and mean over many samples. It uses the native build, because that is what a shipped program is.

blackBox hides a value from the optimizer. Around the input it stops the compiler from precomputing the answer; around the result it keeps the work live. vyrn bench --check runs each body once, compiled, which is what CI does.

hashTo(1000) is 691508967