Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Dec 9, 2018
1 parent 81ec249 commit d2984c4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tests/misc/tinvalidarrayaccess.nim
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
discard """
errormsg: "index out of bounds: (a:0) <= (i:2) <= (b:1) "
line: 11
line: 21
"""

block:
try:
let a = @[1,2]
echo a[3]
except Exception as e:
doAssert e.msg.contains "index out of bounds: (i:3) <= (n:1)"

type TTestArr = array[0..1, int16]
var f: TTestArr
f[0] = 30
f[1] = 40
f[2] = 50
f[3] = 60
block:
type TTestArr = array[0..1, int16]
var f: TTestArr
f[0] = 30
f[1] = 40
f[2] = 50
f[3] = 60

echo(repr(f))
echo(repr(f))
16 changes: 16 additions & 0 deletions tests/misc/tinvalidarrayaccess2.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
discard """
errormsg: "index out of bounds: (a:0) <= (i:3) <= (b:1) "
line: 9
"""

# Note: merge in tinvalidarrayaccess.nim pending https://github.com/nim-lang/Nim/issues/9906

let a = [1,2]
echo a[3]

when false:
# TOOD: this case is not yet handled, giving: "index out of bounds"
proc fun()=
let a = @[1,2]
echo a[3]
static: fun()

0 comments on commit d2984c4

Please sign in to comment.