summary refs log tree commit diff stats
path: root/tests/system
diff options
context:
space:
mode:
authornitely <ecastroborsani@gmail.com>2018-06-05 20:22:27 -0300
committernitely <ecastroborsani@gmail.com>2018-06-05 20:22:27 -0300
commitba39f359aa6b28eb30f7165f9e629373c730b3b2 (patch)
tree4964e2406691a57c7e852c6af4008e6d46a35a03 /tests/system
parent959b6354c126159e5a59c3a021e472380d04e088 (diff)
downloadNim-ba39f359aa6b28eb30f7165f9e629373c730b3b2.tar.gz
check bounds instead of index
Diffstat (limited to 'tests/system')
-rw-r--r--tests/system/tsystem_misc.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/system/tsystem_misc.nim b/tests/system/tsystem_misc.nim
index 85228e9e7..460d94d56 100644
--- a/tests/system/tsystem_misc.nim
+++ b/tests/system/tsystem_misc.nim
@@ -11,6 +11,7 @@ discard """
 2
 3
 4
+2
 '''
 """
 
@@ -47,3 +48,27 @@ foo(toOpenArray(arr, 8, 12))
 
 var seqq = @[1, 2, 3, 4, 5]
 foo(toOpenArray(seqq, 1, 3))
+
+# empty openArray issue #7904
+foo(toOpenArray(seqq, 0, -1))
+foo(toOpenArray(seqq, 1, 0))
+doAssertRaises(IndexError):
+  foo(toOpenArray(seqq, 0, -2))
+
+foo(toOpenArray(arr, 9, 8))
+foo(toOpenArray(arr, 0, -1))
+foo(toOpenArray(arr, 1, 0))
+doAssertRaises(IndexError):
+  foo(toOpenArray(arr, 10, 8))
+
+# test openArray of openArray
+proc oaEmpty(a: openArray[int]) =
+  foo(toOpenArray(a, 0, -1))
+
+proc oaFirstElm(a: openArray[int]) =
+  foo(toOpenArray(a, 0, 0))
+
+oaEmpty(toOpenArray(seqq, 0, -1))
+oaEmpty(toOpenArray(seqq, 1, 0))
+oaEmpty(toOpenArray(seqq, 1, 2))
+oaFirstElm(toOpenArray(seqq, 1, seqq.len-1))