summary refs log tree commit diff stats
path: root/tests/stdlib/tcount.nim
blob: ce1d14b6cf6b5d8c93457644a9e5fc13d650d6be (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
discard """
  output: '''1
2
3
4
5
done'''
"""

# bug #1845, #2224

var arr = [3,2,1,5,4]

# bubble sort
for i in low(arr)..high(arr):
  for j in i+1..high(arr): # Error: unhandled exception: value out of range: 5 [RangeError]
    if arr[i] > arr[j]:
      let tmp = arr[i]
      arr[i] = arr[j]
      arr[j] = tmp

for i in low(arr)..high(arr):
  echo arr[i]

# check this terminates:
for x in countdown('\255', '\0'):
  discard

echo "done"