diff options
Diffstat (limited to 'tests/tseqcon.nim')
-rw-r--r-- | tests/tseqcon.nim | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/tests/tseqcon.nim b/tests/tseqcon.nim index f5d0346ae..935da86b5 100644 --- a/tests/tseqcon.nim +++ b/tests/tseqcon.nim @@ -1,4 +1,7 @@ -# Test the &= operator for sequences and strings +# Test the add proc for sequences and strings + +const + nestedFixed = true type TRec {.final.} = object @@ -8,36 +11,35 @@ type TRecSeq = seq[TRec] proc test() = - var seq, b: seq[string] - seq = [] - add(seq, "Hi") - add(seq, "there, ") - add(seq, "what's your name?") + var s, b: seq[string] + s = @[] + add(s, "Hi") + add(s, "there, ") + add(s, "what's your name?") - b = seq # deep copying here! + b = s # deep copying here! b[0][1] = 'a' - for i in 0 .. length(seq)-1: - write(stdout, seq[i]) - for i in 0 .. length(b)-1: + for i in 0 .. len(s)-1: + write(stdout, s[i]) + for i in 0 .. len(b)-1: write(stdout, b[i]) -when defined(nestedFixed): +when nestedFixed: proc nested() = var - seq: seq[seq[string]] + s: seq[seq[string]] for i in 0..10_000: # test if the garbage collector # now works with sequences - seq = [ - ["A", "B", "C", "D"], - ["E", "F", "G", "H"], - ["I", "J", "K", "L"], - ["M", "N", "O", "P"] - ] + s = @[ + @["A", "B", "C", "D"], + @["E", "F", "G", "H"], + @["I", "J", "K", "L"], + @["M", "N", "O", "P"]] test() -when defined(nestedFixed): +when nestedFixed: nested() #OUT Hithere, what's your name?Hathere, what's your name? |