diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-06-03 21:08:32 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-06-03 21:08:32 +0200 |
commit | 42c9bb3acedd524be23263a8217f34d0100779d9 (patch) | |
tree | f00768910ef07d6392a33a30ef77dcebe27f6a3b /tests | |
parent | d1f5e3b110e92270cfb84218874834054bd7ee64 (diff) | |
download | Nim-42c9bb3acedd524be23263a8217f34d0100779d9.tar.gz |
fixes #5933
Diffstat (limited to 'tests')
-rw-r--r-- | tests/js/tseqops.nim | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/js/tseqops.nim b/tests/js/tseqops.nim new file mode 100644 index 000000000..d10e1ca6a --- /dev/null +++ b/tests/js/tseqops.nim @@ -0,0 +1,51 @@ +discard """ + output: '''(x: 0, y: 0) +(x: 5, y: 0) +@[(x: 2, y: 4), (x: 4, y: 5), (x: 4, y: 5)] +@[(a: 3, b: 3), (a: 1, b: 1), (a: 2, b: 2)] +''' +""" + +# bug #4139 + +type + TestO = object + x, y: int + +proc onLoad() = + var test: seq[TestO] = @[] + var foo = TestO(x: 0, y: 0) + test.add(foo) + foo.x = 5 + echo(test[0]) + echo foo + +onLoad() + +# 'setLen' bug (part of bug #5933) +type MyObj = object + x: cstring + y: int + +proc foo(x: var seq[MyObj]) = + let L = x.len + x.setLen L + 1 + x[L] = x[1] + +var s = @[MyObj(x: "2", y: 4), MyObj(x: "4", y: 5)] +foo(s) +echo s + +# bug #5933 +import sequtils + +type + Test = object + a: cstring + b: int + +var test = @[Test(a: "1", b: 1), Test(a: "2", b: 2)] + +test.insert(@[Test(a: "3", b: 3)], 0) + +echo test |