A test fn takes nothing and returns nothing; zomp test runs each one.
testing.zg
# Tests (owner, 2026-09-29): a `test fn` takes nothing and returns nothing; `zomp test` runs each one.# `must` states what must hold (a comparison shows both sides when it does not), `must.fail` that# something fails (`.not_a_number`: with that reason), `must.stop` that a check site fires. Two of# these fail on purpose. A normal run ignores the tests and runs MAIN.fnadd['a':int32,'b':int32]->int32{return'a'plus'b';}fnwrong['a':int32,'b':int32]->int32{return'a'plus'b'plus1;}testfnadds_up[]{mustadd[2,3]equal_to5;mustadd[2,3]>4;}testfncatches_a_bug[]{mustwrong[2,3]equal_to5;}testfnparsing[]{let'n':=to.int32["42"]otherwise0;must'n'equal_to42;must.failto.int32["abc"];must.fail.not_a_numberto.int32["abc"];}testfnwrong_reason[]{must.fail.out_of_rangeto.int32["abc"];}testfnguards[]{let'xs':list[int32]=[1,2,3];must.stop'xs'[pos99];}MAIN{std::print.useful[add[1,1],newln];}
Output, then zomp test
2
test adds_up ... ok
test catches_a_bug ... FAILED: line 12 of testing.zg: `must` does not hold: the left side is 6, and it must be `equal_to` 5
test parsing ... ok
test wrong_reason ... FAILED: line 21 of testing.zg: `must.fail.out_of_range`: it failed with `not_a_number`
test guards ... ok
5 tests: 3 passed, 2 failed