Module macro.assert

a simple testing framework.

Defines a single statment macro assert_ which has the following syntax:

  • assert_ val1 == val2
  • assert_ val1 > val2
  • assert_ val1 < val2
  • assert_ val1 matches val2 (using string matching)
  • assert_ val1 throws val2 (ditto, on exception string)

The == case has some special forms. If val2 is (v1,v2,..) then it's assumed that the expression val1 returns multiple values. == will also do value equality for plain tables. If val2 is a number given in %f format (such as 3.14) then it will match vall up to that specified number of digits.

 assert_ {one=1,two=2} == {two=2,one=1}
 assert_ 'hello' matches '^hell'
 assert_ 2 > 1
 assert_ ('hello'):find 'll' == (3,4)
 assert_ a.x throws 'attempt to index global'

Macros

assert_ assert that two values match the desired relation.


Macros

assert_
assert that two values match the desired relation.