-assert

The -assert signal is mostly used for testing. It can be used to assert that certain conditions are met when control passes through the signal. The -assert signal has multiple forms, demonstrated below.

const 2
push
const 3
add
-assert,acc,5
push
const 0
lt
jz after
-assert,does_not_reach
const "failure"
after:
const "awesome"
...

The -assert,acc signal checks that the accumulator has the specified value. The suggested value can be any primitive, but not reference types. The -assert,does_not_reach throws an error if control passes through it. This is useful for ensuring that control goes in a certain direction.

Another -assert signal is -assert,error. This signal throws an error if the execution of the bytecode does not throw an error. This is mainly used for testing, to confirm (for instance) that certain instruction are typesafe.



Mason Smith 2008-06-11