summary refs log tree commit diff stats
path: root/tests/stdlib/tcount.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdlib/tcount.nim')
-rw-r--r--tests/stdlib/tcount.nim29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/stdlib/tcount.nim b/tests/stdlib/tcount.nim
new file mode 100644
index 000000000..ce1d14b6c
--- /dev/null
+++ b/tests/stdlib/tcount.nim
@@ -0,0 +1,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"