trangechecks.nim 530 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 OverflowDefect, RangeDefect:
  15. expected += 1
  16. echo x
  17. try:
  18. inc x
  19. echo x
  20. except OverflowDefect, RangeDefect:
  21. expected += 1
  22. echo x
  23. x = 1
  24. try:
  25. x -= 1
  26. echo x
  27. except OverflowDefect, RangeDefect:
  28. expected += 1
  29. echo x
  30. try:
  31. dec x
  32. echo x
  33. except OverflowDefect, RangeDefect:
  34. expected += 1
  35. echo x
  36. echo expected == 4
  37. # bug #13698
  38. var
  39. x45 = "hello".cstring
  40. p = x45.len.int32