diff options
Diffstat (limited to 'tests/array/tarray.nim')
-rw-r--r-- | tests/array/tarray.nim | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/tests/array/tarray.nim b/tests/array/tarray.nim index 27288bab3..e9f330e3b 100644 --- a/tests/array/tarray.nim +++ b/tests/array/tarray.nim @@ -1,11 +1,8 @@ discard """ output: ''' [4, 5, 6] - [16, 25, 36] - [16, 25, 36] - apple banana Fruit @@ -47,7 +44,7 @@ block tarray: arr: TMyarray - proc sum(a: openarray[int]): int = + proc sum(a: openArray[int]): int = result = 0 var i = 0 while i < len(a): @@ -347,11 +344,11 @@ block troofregression: if $a != b: echo "Failure ", a, " != ", b - check type(4 ...< 1), "HSlice[system.int, system.int]" - check type(4 ...< ^1), "HSlice[system.int, system.BackwardsIndex]" - check type(4 ... pred(^1)), "HSlice[system.int, system.BackwardsIndex]" - check type(4 ... mypred(8)), "HSlice[system.int, system.int]" - check type(4 ... mypred(^1)), "HSlice[system.int, system.BackwardsIndex]" + check typeof(4 ...< 1), "HSlice[system.int, system.int]" + check typeof(4 ...< ^1), "HSlice[system.int, system.BackwardsIndex]" + check typeof(4 ... pred(^1)), "HSlice[system.int, system.BackwardsIndex]" + check typeof(4 ... mypred(8)), "HSlice[system.int, system.int]" + check typeof(4 ... mypred(^1)), "HSlice[system.int, system.BackwardsIndex]" var rot = 8 @@ -590,3 +587,21 @@ block t12466: a[0'u16 + i] = i for i in 0'u16 ..< 8'u16: a[0'u16 + i] = i + +block t17705: + # https://github.com/nim-lang/Nim/pull/17705 + var a = array[0, int].low + a = int(a) + var b = array[0, int].high + b = int(b) + +block t18643: + # https://github.com/nim-lang/Nim/issues/18643 + let a: array[0, int] = [] + var caught = false + let b = 9999999 + try: + echo a[b] + except IndexDefect: + caught = true + doAssert caught, "IndexDefect not caught!" |