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.




require "test/unit/assertions"
include Test::Unit::Assertions
 
n = 5
begin
  assert_equal(42, n)
rescue Exception => e
  # Ruby 1.8: e is a Test::Unit::AssertionFailedError
  # Ruby 1.9: e is a MiniTest::Assertion
  puts e
end