summary refs log tree commit diff stats
path: root/tests/openarray/tptrarrayderef.nim
diff options
context:
space:
mode:
authorJasper Jenkins <jasper.vs.jenkins@gmail.com>2019-05-06 23:14:38 -0700
committerAndreas Rumpf <rumpf_a@web.de>2019-05-07 08:14:38 +0200
commita6ba3116b2376d9f3476ef0f8db5bbb32afc2a76 (patch)
tree325d1c688970c410fa6e452a84b670fa196ffd1c /tests/openarray/tptrarrayderef.nim
parent7804b5c55888717b35432c2670f4eef23afd583a (diff)
downloadNim-a6ba3116b2376d9f3476ef0f8db5bbb32afc2a76.tar.gz
Fixes for ptr array deref codegen (#11191)
* fixes for ptr array derefence codegen
* fix comments, make diff nicer
Diffstat (limited to 'tests/openarray/tptrarrayderef.nim')
-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"