new tester; all tests categorized
This commit is contained in:
parent
51ee524109
commit
20b5f31c03
481 changed files with 794 additions and 2506 deletions
31
tests/assign/tassign.nim
Normal file
31
tests/assign/tassign.nim
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Test the assignment operator for complex types which need RTTI
|
||||
|
||||
type
|
||||
TRec = object
|
||||
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 = @[]
|
||||
setLen(a.arr, 4)
|
||||
a.arr[0] = @[]
|
||||
a.arr[1] = @[]
|
||||
|
||||
b = a # perform a deep copy here!
|
||||
b.seq = @["xyz", "huch", "was", "soll"]
|
||||
writeln(stdout, len(a.seq))
|
||||
writeln(stdout, a.seq[3])
|
||||
writeln(stdout, len(b.seq))
|
||||
writeln(stdout, b.seq[3])
|
||||
writeln(stdout, b.y)
|
||||
|
||||
test()
|
||||
Loading…
Add table
Add a link
Reference in a new issue