From 405b86068e6a3d39970b9129ceec0a9108464b28 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 22 Jun 2008 16:14:11 +0200 Subject: Initial import --- tests/tassign.nim | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tests/tassign.nim (limited to 'tests/tassign.nim') diff --git a/tests/tassign.nim b/tests/tassign.nim new file mode 100755 index 000000000..8f98ad0f3 --- /dev/null +++ b/tests/tassign.nim @@ -0,0 +1,34 @@ +# Test the assignment operator for complex types which need RTTI + +import + io + +type + TRec = record + x, y: int + s: string + seq: seq[string] + arr: seq[seq[array[0..3, string]]] + TRecSeq = seq[TRec] + +proc test() = + var + a, b: TRec + a.x = 1 + a.y = 2 + a.s = "Hallo!" + a.seq = ["abc", "def", "ghi", "jkl"] + a.arr = [] + setLength(a.arr, 4) + a.arr[0] = [] + a.arr[1] = [] + + b = a # perform a deep copy here! + b.seq = ["xyz", "huch", "was", "soll"] + writeln(stdout, length(a.seq)) + writeln(stdout, a.seq[3]) + writeln(stdout, length(b.seq)) + writeln(stdout, b.seq[3]) + writeln(stdout, b.y) + +test() -- cgit 1.4.1-2-gfad0