summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-12-18 07:54:20 +0100
committerGitHub <noreply@github.com>2019-12-18 07:54:20 +0100
commit3f6df5cc3475573807fae9854fe1616535f93412 (patch)
treea43cf259fda740cda061d96d657271253b32af4a /tests
parentf9f55a23bbcb64824954ed83b60816499a7cc338 (diff)
downloadNim-3f6df5cc3475573807fae9854fe1616535f93412.tar.gz
fixes #12899 (#12921)
* fixes #12899

* fixes regression: destroy global variables in reverse declaration order, closureleak test relies on it
Diffstat (limited to 'tests')
-rw-r--r--tests/destructor/tnewruntime_strutils.nim26
-rw-r--r--tests/gc/closureleak.nim4
2 files changed, 27 insertions, 3 deletions
diff --git a/tests/destructor/tnewruntime_strutils.nim b/tests/destructor/tnewruntime_strutils.nim
index 3e4ee27be..74cd985ab 100644
--- a/tests/destructor/tnewruntime_strutils.nim
+++ b/tests/destructor/tnewruntime_strutils.nim
@@ -1,7 +1,9 @@
 discard """
   valgrind: true
   cmd: '''nim c --newruntime -d:useMalloc $file'''
-  output: '''422 422'''
+  output: '''
+@[(input: @["KXSC", "BGMC"]), (input: @["PXFX"]), (input: @["WXRQ", "ZSCZD"])]
+461 461'''
 """
 
 import strutils, os, std / wordwrap
@@ -13,6 +15,28 @@ import system / ansi_c
 proc retTuple(): (seq[int], int) =
   return (@[1], 1)
 
+# bug #12899
+
+import sequtils, strmisc
+
+const input = ["KXSC, BGMC => 7 PTHL", "PXFX => LBZJ", "WXRQ, ZSCZD => HLQM"]
+
+type
+  Reaction = object
+    input: seq[string]
+
+proc bug12899 =
+  var reactions: seq[Reaction] = @[]
+  for l in input:
+    let x = l.partition(" => ")
+    reactions.add Reaction(input: @(x[0].split(", ")))
+
+  let x = $reactions
+  echo x
+
+bug12899()
+
+
 proc nonStaticTests =
   doAssert formatBiggestFloat(1234.567, ffDecimal, -1) == "1234.567000"
   doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235" # bugs 8242, 12586
diff --git a/tests/gc/closureleak.nim b/tests/gc/closureleak.nim
index 508004a53..0265431d0 100644
--- a/tests/gc/closureleak.nim
+++ b/tests/gc/closureleak.nim
@@ -6,7 +6,7 @@ discard """
 type
   TFoo* = object
     id: int
-    fn: proc(){.closure.}
+    fn: proc() {.closure.}
 var foo_counter = 0
 var alive_foos = newseq[int](0)
 
@@ -31,7 +31,7 @@ proc newFoo*(): ref TFoo =
   inc foo_counter
 
 for i in 0 ..< 10:
- discard newFoo()
+  discard newFoo()
 
 for i in 0 ..< 10:
   let f = newFoo()