summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2018-04-22 18:11:22 +0300
committerZahary Karadjov <zahary@gmail.com>2018-06-16 16:46:32 +0300
commitab9969ed3be2d57fdeda170cc9960be7ba628149 (patch)
tree9b36a31c68842e4c2ca835aec1085aa3adfafebc /tests
parent509d6e923284f1f02c5dbc64e43aee9df1a012d3 (diff)
downloadNim-ab9969ed3be2d57fdeda170cc9960be7ba628149.tar.gz
Bugfix: the size of an array may be a static tuple element
Diffstat (limited to 'tests')
-rw-r--r--tests/statictypes/tstatictypes.nim40
1 files changed, 33 insertions, 7 deletions
diff --git a/tests/statictypes/tstatictypes.nim b/tests/statictypes/tstatictypes.nim
index a646b61f7..5234866fa 100644
--- a/tests/statictypes/tstatictypes.nim
+++ b/tests/statictypes/tstatictypes.nim
@@ -5,13 +5,39 @@ staticAlialProc instantiated with 6
 '''
 """
 
-type
-  StaticTypeAlias = static[int]
+import macros
 
-proc staticAliasProc(s: StaticTypeAlias) =
-  static: echo "staticAlialProc instantiated with ", s + 1
+proc plus(a, b: int): int = a + b
 
-staticAliasProc 1+2
-staticAliasProc 3
-staticAliasProc 5
+when true:
+  type
+    StaticTypeAlias = static[int]
+
+  proc staticAliasProc(s: StaticTypeAlias) =
+    static: echo "staticAlialProc instantiated with ", s + 1
+    echo s
+
+  staticAliasProc 1+2
+  staticAliasProc 3
+  staticAliasProc 5
+
+when true:
+  type
+    ArrayWrapper1[S: static int] = object
+      data: array[S + 1, int]
+
+    ArrayWrapper2[S: static[int]] = object
+      data: array[S.plus(2), int]
+
+    ArrayWrapper3[S: static[(int, string)]] = object
+      data: array[S[0], int]
+
+  var aw1: ArrayWrapper1[5]
+  var aw2: ArrayWrapper2[5]
+  var aw3: ArrayWrapper3[(10, "str")]
+  
+  static:
+    assert aw1.data.high == 5
+    assert aw2.data.high == 6
+    assert aw3.data.high == 9