diff options
Diffstat (limited to 'tests/seq')
-rw-r--r-- | tests/seq/tseq2.nim | 4 | ||||
-rw-r--r-- | tests/seq/tseqcon.nim | 90 | ||||
-rw-r--r-- | tests/seq/tseqtuple.nim | 2 | ||||
-rw-r--r-- | tests/seq/ttoseq.nim | 4 |
4 files changed, 50 insertions, 50 deletions
diff --git a/tests/seq/tseq2.nim b/tests/seq/tseq2.nim index e1271964c..5de9402ec 100644 --- a/tests/seq/tseq2.nim +++ b/tests/seq/tseq2.nim @@ -1,10 +1,10 @@ -proc `*` *(a, b: seq[int]): seq[int] = +proc `*` *(a, b: seq[int]): seq[int] = # allocate a new sequence: newSeq(result, len(a)) # multiply two int sequences: for i in 0..len(a)-1: result[i] = a[i] * b[i] -when isMainModule: +when isMainModule: # test the new ``*`` operator for sequences: assert(@[1, 2, 3] * @[1, 2, 3] == @[1, 4, 9]) diff --git a/tests/seq/tseqcon.nim b/tests/seq/tseqcon.nim index 6e0a5b56d..902ac3485 100644 --- a/tests/seq/tseqcon.nim +++ b/tests/seq/tseqcon.nim @@ -2,50 +2,50 @@ discard """ file: "tseqcon.nim" output: "Hithere, what\'s your name?Hathere, what\'s your name?" """ -# 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? +# 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? diff --git a/tests/seq/tseqtuple.nim b/tests/seq/tseqtuple.nim index 7ef92f7f1..a0102c9ef 100644 --- a/tests/seq/tseqtuple.nim +++ b/tests/seq/tseqtuple.nim @@ -6,7 +6,7 @@ discard """ type TMsg = tuple[ file: string, - line: int, + line: int, msg: string, err: bool] diff --git a/tests/seq/ttoseq.nim b/tests/seq/ttoseq.nim index 34cc4824b..33de59538 100644 --- a/tests/seq/ttoseq.nim +++ b/tests/seq/ttoseq.nim @@ -4,9 +4,9 @@ discard """ import sequtils -for x in toSeq(countup(2, 6)): +for x in toSeq(countup(2, 6)): stdout.write(x) -for x in items(toSeq(countup(2, 6))): +for x in items(toSeq(countup(2, 6))): stdout.write(x) import strutils |