summary refs log tree commit diff stats
path: root/tests/tassign.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <andreas@andi>2008-06-22 16:14:11 +0200
committerAndreas Rumpf <andreas@andi>2008-06-22 16:14:11 +0200
commit405b86068e6a3d39970b9129ceec0a9108464b28 (patch)
treec0449946f54baae6ea88baf453157ddd7faa8f86 /tests/tassign.nim
downloadNim-405b86068e6a3d39970b9129ceec0a9108464b28.tar.gz
Initial import
Diffstat (limited to 'tests/tassign.nim')
-rwxr-xr-xtests/tassign.nim34
1 files changed, 34 insertions, 0 deletions
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()