Assertions are a way of breaking out of code when there is an error or an unexpected input.

Some languages throw exceptions and some treat it as a break point.



Task

Show an assertion in your language by asserting that an integer variable is equal to 42.




/* REXX ***************************************************************
* There's no assert feature in Rexx. That's how I'd implement it
* 10.08.2012 Walter Pachl
**********************************************************************/
x.=42
x.2=11
Do i=1 By 1
  Call assert x.i,42
  End
Exit
assert:
  Parse Arg assert_have,assert_should_have
  If assert_have\==assert_should_have Then Do
    Say 'Assertion fails in line' sigl
    Say 'expected:' assert_should_have
    Say '   found:' assert_have
    Say sourceline(sigl)
    Say 'Look around'
    Trace ?R
    Nop
    Signal Syntax
    End
  Return
Syntax: Say 'program terminated'