trangechecks.nim 460 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. discard """
  2. output: '''10
  3. 10
  4. 1
  5. 1
  6. true'''
  7. """
  8. # bug #1344
  9. var expected: int
  10. var x: range[1..10] = 10
  11. try:
  12. x += 1
  13. echo x
  14. except OverflowError, RangeError:
  15. expected += 1
  16. echo x
  17. try:
  18. inc x
  19. echo x
  20. except OverflowError, RangeError:
  21. expected += 1
  22. echo x
  23. x = 1
  24. try:
  25. x -= 1
  26. echo x
  27. except OverflowError, RangeError:
  28. expected += 1
  29. echo x
  30. try:
  31. dec x
  32. echo x
  33. except OverflowError, RangeError:
  34. expected += 1
  35. echo x
  36. echo expected == 4