The Assert method



Using the Assert method.
Smart pascal source code
var v = True; Begin Assert(1=1, 'should optimize itself away'); Assert(v); try Assert(not v); except on E: EAssertionFailed do WriteLn(E.Message); // Assertion failed end; Assert(v, 'bug'); try Assert(not v, 'boom'); except on E: EAssertionFailed do WriteLn(E.Message); // Assertion failed : boom end; Assert(True); try Assert(False); except on E: EAssertionFailed do WriteLn(E.Message); // Assertion failed end; Assert(True, 'rebug'); try Assert(False, 'reboom'); except on E: EAssertionFailed do WriteLn(E.Message); // Assertion failed : reboom end; { CONSOLE OUTPUT Assertion failed Assertion failed : boom Assertion failed Assertion failed : reboom }