mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 01:44:37 +00:00
44 lines
460 B
Nim
44 lines
460 B
Nim
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
|