summary refs log tree commit diff stats
path: root/tests/openarray
diff options
context:
space:
mode:
Diffstat (limited to 'tests/openarray')
-rw-r--r--tests/openarray/tptrarrayderef.nim18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/openarray/tptrarrayderef.nim b/tests/openarray/tptrarrayderef.nim
index 5c63f6f98..b75bc08c4 100644
--- a/tests/openarray/tptrarrayderef.nim
+++ b/tests/openarray/tptrarrayderef.nim
@@ -1,5 +1,8 @@
 discard """
-  output: "OK"
+  output: '''[1, 2, 3, 4]
+3
+OK
+'''
 """
 
 var
@@ -50,4 +53,17 @@ let aa = getFilledBuffer(3)
 for i in 0..aa[].len-1:
   doAssert(aa[i] == chr(i))
 
+var
+  x = [1, 2, 3, 4]
+  y1 = block: (
+    a: (block:
+      echo x
+      cast[ptr array[2, int]](addr(x[0]))[]),
+    b: 3)
+  y2 = block:
+    echo y1.a[0] + y1.a[1]
+    cast[ptr array[4, int]](addr(x))[]
+doAssert y1 == ([1, 2], 3)
+doAssert y2 == [1, 2, 3, 4]
+
 echo "OK"