summary refs log tree commit diff stats
path: root/tests/system/tnilconcats.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/system/tnilconcats.nim')
-rw-r--r--tests/system/tnilconcats.nim33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/system/tnilconcats.nim b/tests/system/tnilconcats.nim
new file mode 100644
index 000000000..69fc3913c
--- /dev/null
+++ b/tests/system/tnilconcats.nim
@@ -0,0 +1,33 @@
+discard """
+  output: '''@["", "", "", "", "", "", "", "meh"]'''
+  exitcode: "0"
+"""
+
+when true:
+  var ab: string
+  ab &= "more"
+
+  doAssert ab == "more"
+
+  var x: seq[string]
+
+  setLen(x, 7)
+
+  x.add "meh"
+
+  var s: string
+  var z = "abc"
+  var zz: string
+  s &= "foo" & z & zz
+
+  doAssert s == "fooabc"
+
+  echo x
+
+  # casting an empty string as sequence with shallow() should not segfault
+  var s2: string
+  when defined(gcRefc):
+    shallow(s2)
+  s2 &= "foo"
+  doAssert s2 == "foo"
+