summary refs log tree commit diff stats
path: root/tests/destructor/tnewruntime_misc.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-08-07 22:40:58 +0200
committerGitHub <noreply@github.com>2019-08-07 22:40:58 +0200
commitc0d240b8cd3dc08d25c671b0dc7614fbfa980c2e (patch)
tree82ca82c0cd8d8dc7bd164d352d9b5a1910cd7164 /tests/destructor/tnewruntime_misc.nim
parentf34ae81971ada93fd4fda871c3da6cba9aab8bff (diff)
downloadNim-c0d240b8cd3dc08d25c671b0dc7614fbfa980c2e.tar.gz
fixes #11807 (#11900)
* fixes #11807
* make tests green again
Diffstat (limited to 'tests/destructor/tnewruntime_misc.nim')
-rw-r--r--tests/destructor/tnewruntime_misc.nim50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/destructor/tnewruntime_misc.nim b/tests/destructor/tnewruntime_misc.nim
new file mode 100644
index 000000000..029a2a78d
--- /dev/null
+++ b/tests/destructor/tnewruntime_misc.nim
@@ -0,0 +1,50 @@
+discard """
+  cmd: '''nim cpp --newruntime $file'''
+  output: '''(field: "value")
+Indeed
+0  new: 0'''
+"""
+
+import core / allocators
+import system / ansi_c
+
+import tables
+
+type
+  Node = ref object
+    field: string
+
+# bug #11807
+import os
+putEnv("HEAPTRASHING", "Indeed")
+
+proc main =
+  var w = newTable[string, owned Node]()
+  w["key"] = Node(field: "value")
+  echo w["key"][]
+  echo getEnv("HEAPTRASHING")
+
+main()
+
+# bug #11745
+
+type
+  Foo = object
+    bar: seq[int]
+
+var x = [Foo()]
+
+# bug #11563
+type
+  MyTypeType = enum
+    Zero, One
+  MyType = object
+    case kind: MyTypeType
+    of Zero:
+      s*: seq[MyType]
+    of One:
+      x*: int
+var t: MyType
+
+let (a, d) = allocCounters()
+discard cprintf("%ld  new: %ld\n", a - unpairedEnvAllocs() - d, allocs)