summary refs log tree commit diff stats
path: root/tests/vm
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-03-05 09:54:59 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-03-05 09:54:59 +0100
commit142a2d355123155fb6ef600f269687703e554224 (patch)
treebeab41551e33d59601fea19d3a210ef56c1d2dbd /tests/vm
parent2dc8a323242b639875d24d1baa7c8c9da2055fe2 (diff)
downloadNim-142a2d355123155fb6ef600f269687703e554224.tar.gz
added system.default in order to prevent the abstraction inversion that 'template default(T): untyped = (var x: T; x)' causes
Diffstat (limited to 'tests/vm')
-rw-r--r--tests/vm/treset.nim27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/vm/treset.nim b/tests/vm/treset.nim
index 56fe19b19..ff8bc5b83 100644
--- a/tests/vm/treset.nim
+++ b/tests/vm/treset.nim
@@ -1,3 +1,6 @@
+discard """
+  output: '''0'''
+"""
 static:
   type Obj = object
     field: int
@@ -5,6 +8,17 @@ static:
   reset(o)
   doAssert o.field == 0
 
+  var x = 4
+  reset(x)
+  doAssert x == 0
+
+static:
+  type ObjB = object
+    field: int
+  var o = ObjB(field: 1)
+  o = default(ObjB)
+  doAssert o.field == 0
+
 static:
   var i = 2
   reset(i)
@@ -25,4 +39,15 @@ static:
     var i = 2
     reset(i)
     doAssert i == 0
-  f()
\ No newline at end of file
+  f()
+
+proc main =
+  var y = [1, 2, 3, 4]
+  y = default(array[4, int])
+  for a in y: doAssert(a == 0)
+
+  var x = 4
+  x = default(int)
+  echo x
+
+main()