summary refs log tree commit diff stats
path: root/tests/accept/run/tseqcon.nim
diff options
context:
space:
mode:
authorrumpf_a@web.de <>2010-02-21 19:42:36 +0100
committerrumpf_a@web.de <>2010-02-21 19:42:36 +0100
commitd913fdb2800d83680e413cd8a5f07b7f85deac6e (patch)
tree09a284861adf96520059f211ba8bae1a76294a9c /tests/accept/run/tseqcon.nim
parent6bc16904edd3738ab97573b9eeb3a6a7cce9574c (diff)
downloadNim-d913fdb2800d83680e413cd8a5f07b7f85deac6e.tar.gz
start of tests refactoring; sqlite3 new wrapper fixes
Diffstat (limited to 'tests/accept/run/tseqcon.nim')
-rw-r--r--tests/accept/run/tseqcon.nim45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/accept/run/tseqcon.nim b/tests/accept/run/tseqcon.nim
new file mode 100644
index 000000000..935da86b5
--- /dev/null
+++ b/tests/accept/run/tseqcon.nim
@@ -0,0 +1,45 @@
+# Test the add proc for sequences and strings

+

+const

+  nestedFixed = true

+

+type

+  TRec {.final.} = object

+    x, y: int

+    s: string

+    seq: seq[string]

+  TRecSeq = seq[TRec]

+

+proc test() =

+  var s, b: seq[string]

+  s = @[]

+  add(s, "Hi")

+  add(s, "there, ")

+  add(s, "what's your name?")

+

+  b = s # deep copying here!

+  b[0][1] = 'a'

+

+  for i in 0 .. len(s)-1:

+    write(stdout, s[i])

+  for i in 0 .. len(b)-1:

+    write(stdout, b[i])

+

+

+when nestedFixed:

+  proc nested() =

+    var

+      s: seq[seq[string]]

+    for i in 0..10_000: # test if the garbage collector

+      # now works with sequences

+      s = @[

+        @["A", "B", "C", "D"],

+        @["E", "F", "G", "H"],

+        @["I", "J", "K", "L"],

+        @["M", "N", "O", "P"]]

+

+test()

+when nestedFixed:

+  nested()

+

+#OUT Hithere, what's your name?Hathere, what's your name?