tassert.nim 462 B

123456789101112131415161718192021
  1. discard """
  2. outputsub: "assertion failure!this shall be always written"
  3. exitcode: "1"
  4. """
  5. # test assert and exception handling
  6. proc callB() = assert(false)
  7. proc callA() = callB()
  8. proc callC() = callA()
  9. try:
  10. callC()
  11. except AssertionDefect:
  12. write(stdout, "assertion failure!")
  13. except:
  14. write(stdout, "unknown exception!")
  15. finally:
  16. system.write(stdout, "this shall be always written")
  17. assert(false) #OUT assertion failure!this shall be always written