diff options
Diffstat (limited to 'tests/array')
-rw-r--r-- | tests/array/t15117.nim | 27 | ||||
-rw-r--r-- | tests/array/t20248.nim | 14 | ||||
-rw-r--r-- | tests/array/tinvalidarrayaccess.nim | 21 | ||||
-rw-r--r-- | tests/array/tinvalidarrayaccess2.nim | 10 | ||||
-rw-r--r-- | tests/array/tlargeindex.nim | 18 |
5 files changed, 90 insertions, 0 deletions
diff --git a/tests/array/t15117.nim b/tests/array/t15117.nim new file mode 100644 index 000000000..157b04bee --- /dev/null +++ b/tests/array/t15117.nim @@ -0,0 +1,27 @@ +discard """ + matrix: "--cc:vcc" + disabled: "linux" + disabled: "bsd" + disabled: "osx" + disabled: "unix" + disabled: "posix" +""" +{.experimental: "views".} + +let a: array[0, byte] = [] +discard a + +type B = object + a:int +let b: array[0, B] = [] +let c: array[0, ptr B] = [] +let d: array[0, ref B] = [] +discard b +discard c +discard d + +discard default(array[0, B]) + +type + View1 = openArray[byte] +discard default(View1) diff --git a/tests/array/t20248.nim b/tests/array/t20248.nim new file mode 100644 index 000000000..66142548b --- /dev/null +++ b/tests/array/t20248.nim @@ -0,0 +1,14 @@ +discard """ +cmd: "nim check --hints:off $file" +errormsg: "ordinal type expected; given: Error Type" +nimout: ''' +t20248.nim(10, 36) Error: ordinal type expected; given: Error Type +t20248.nim(14, 20) Error: ordinal type expected; given: Error Type +''' +""" + +type Vec[N: static[int]] = array[0 ..< N, float] + +var v: Vec[32] + +var stuff: array[0 ..< 16, int] diff --git a/tests/array/tinvalidarrayaccess.nim b/tests/array/tinvalidarrayaccess.nim new file mode 100644 index 000000000..f8bce45ef --- /dev/null +++ b/tests/array/tinvalidarrayaccess.nim @@ -0,0 +1,21 @@ +discard """ + errormsg: "index 2 not in 0 .. 1" + line: 18 +""" +block: + try: + let a = @[1,2] + echo a[3] + except Exception as e: + doAssert e.msg == "index 3 not in 0 .. 1" + # note: this is not being tested, because the CT error happens before + +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)) diff --git a/tests/array/tinvalidarrayaccess2.nim b/tests/array/tinvalidarrayaccess2.nim new file mode 100644 index 000000000..0a0703834 --- /dev/null +++ b/tests/array/tinvalidarrayaccess2.nim @@ -0,0 +1,10 @@ +discard """ + errormsg: "index 3 not in 0 .. 1" + line: 9 +""" + +# Note: merge in tinvalidarrayaccess.nim pending https://github.com/nim-lang/Nim/issues/9906 + +let a = [1,2] +echo a[3] + diff --git a/tests/array/tlargeindex.nim b/tests/array/tlargeindex.nim new file mode 100644 index 000000000..61bcbd61d --- /dev/null +++ b/tests/array/tlargeindex.nim @@ -0,0 +1,18 @@ +discard """ + cmd: "nim check --hints:off $file" +""" + +# issue #17163 +var e: array[int32, byte] #[tt.Error + ^ index type 'int32' for array is too large]# +var f: array[uint32, byte] #[tt.Error + ^ index type 'uint32' for array is too large]# +var g: array[int64, byte] #[tt.Error + ^ index type 'int64' for array is too large]# +var h: array[uint64, byte] #[tt.Error + ^ index type 'uint64' for array is too large]# + +# crash in issue #23204 +proc y[N](): array[N, int] = default(array[N, int]) #[tt.Error + ^ index type 'int' for array is too large]# +discard y[int]() |