summary refs log tree commit diff stats
path: root/tests/misc/trangechecks.nim
blob: 2c6f0f66d3fb7a621355f8f13c466e96833ddff7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
discard """
  output: '''10
10
1
1
true'''
"""

# bug #1344

var expected: int
var x: range[1..10] = 10

try:
  x += 1
  echo x
except OverflowError, RangeError:
  expected += 1
  echo x

try:
  inc x
  echo x
except OverflowError, RangeError:
  expected += 1
  echo x

x = 1
try:
  x -= 1
  echo x
except OverflowError, RangeError:
  expected += 1
  echo x

try:
  dec x
  echo x
except OverflowError, RangeError:
  expected += 1
  echo x

echo expected == 4