tcppraise.nim 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. discard """
  2. targets: "cpp"
  3. output: '''foo
  4. bar
  5. Need odd and >= 3 digits##
  6. baz
  7. caught
  8. --------
  9. Triggered raises2
  10. Raising ValueError
  11. '''
  12. """
  13. # bug #1888
  14. echo "foo"
  15. try:
  16. echo "bar"
  17. raise newException(ValueError, "Need odd and >= 3 digits")
  18. # echo "baz"
  19. except ValueError:
  20. echo getCurrentExceptionMsg(), "##"
  21. echo "baz"
  22. # bug 7232
  23. try:
  24. discard
  25. except KeyError, ValueError:
  26. echo "except handler" # should not be invoked
  27. #bug 7239
  28. try:
  29. try:
  30. raise newException(ValueError, "asdf")
  31. except KeyError, ValueError:
  32. raise
  33. except:
  34. echo "caught"
  35. # issue 5549
  36. var strs: seq[string] = @[]
  37. try:
  38. discard
  39. finally:
  40. for foobar in strs:
  41. discard
  42. # issue #11118
  43. echo "--------"
  44. proc raises() =
  45. raise newException(ValueError, "Raising ValueError")
  46. proc raises2() =
  47. try:
  48. raises()
  49. except ValueError as e:
  50. echo "Triggered raises2"
  51. raise e
  52. try:
  53. raises2()
  54. except:
  55. echo getCurrentExceptionMsg()
  56. discard
  57. doAssert: getCurrentException() == nil